Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include elasticsearch statefulset nodes in availability check #371

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 28 additions & 7 deletions pkg/controller/jaeger/elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,39 @@ func waitForAvailableElastic(c client.Client, es esv1.Elasticsearch) error {
}
return false, err
}
available := int32(0)
availableDep := int32(0)
for _, d := range depList.Items {
if d.Status.Replicas == d.Status.AvailableReplicas {
available++
availableDep++
}
}
ssList := corev1.StatefulSetList{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the relationship between the deployment above and this stateful set? Is it sufficient to just check the stateful set?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SS is used exclusively for only master nodes. The deployments are used for data or other combinations.

if err = c.List(context.Background(), client.MatchingLabels(labels).InNamespace(es.Namespace), &ssList); err != nil {
if k8serrors.IsNotFound(err) {
// the object might have not been created yet
log.WithFields(log.Fields{
"namespace": es.Namespace,
"name": es.Name,
}).Debug("Elasticsearch cluster doesn't exist yet.")
return false, nil
}
return false, err
}
ssAvailableRep := int32(0)
ssReplicas := int32(0)
for _, s := range ssList.Items {
ssReplicas += *s.Spec.Replicas
ssAvailableRep += s.Status.ReadyReplicas
}
logrus.WithFields(logrus.Fields{
"namespace": es.Namespace,
"name": es.Name,
"desiredNodes": expectedSize,
"availableNodes": available,
"namespace": es.Namespace,
"name": es.Name,
"desiredESNodes": expectedSize,
"desiredStatefulSetNodes": ssReplicas,
"availableStatefulSetNodes": ssAvailableRep,
"desiredDeploymentNodes": expectedSize - ssReplicas,
"availableDeploymentNodes": availableDep,
}).Debug("Waiting for Elasticsearch to be available")
return available == expectedSize, nil
return availableDep+ssAvailableRep == expectedSize, nil
})
}