Skip to content

Commit

Permalink
Include elasticsearch statefulset nodes in availability check (#371)
Browse files Browse the repository at this point in the history
* Include elasticsearch statefulset nodes in availability check

Signed-off-by: Pavol Loffay <ploffay@redhat.com>

* Split SS and deployment nodes in log message

Signed-off-by: Pavol Loffay <ploffay@redhat.com>
  • Loading branch information
pavolloffay authored Apr 16, 2019
1 parent 20c68a9 commit 4174554
Showing 1 changed file with 28 additions and 7 deletions.
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{}
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
})
}

0 comments on commit 4174554

Please sign in to comment.