Skip to content

Commit 53f16ed

Browse files
Create missing statefulsets before waiting for ready (#227)
Co-authored-by: Matt Schallert <[email protected]>
1 parent a052641 commit 53f16ed

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

pkg/controller/controller.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -436,13 +436,6 @@ func (c *M3DBController) handleClusterUpdate(cluster *myspec.M3DBCluster) error
436436
childrenSetsByName := make(map[string]*appsv1.StatefulSet)
437437
for _, sts := range childrenSets {
438438
childrenSetsByName[sts.Name] = sts
439-
// if any of the statefulsets aren't ready, wait until they are as we'll get
440-
// another event (ready == bootstrapped)
441-
if sts.Spec.Replicas != nil && *sts.Spec.Replicas != sts.Status.ReadyReplicas {
442-
// TODO(schallert): figure out what to do if replicas is not set
443-
c.logger.Info("waiting for statefulset to be ready", zap.String("name", sts.Name), zap.Int32("ready", sts.Status.ReadyReplicas))
444-
return nil
445-
}
446439
}
447440

448441
// Create any missing statefulsets, at this point all existing stateful sets are bootstrapped.
@@ -466,6 +459,16 @@ func (c *M3DBController) handleClusterUpdate(cluster *myspec.M3DBCluster) error
466459
}
467460
}
468461

462+
// If any of the statefulsets aren't ready, wait until they are as we'll get
463+
// another event (ready == bootstrapped)
464+
for _, sts := range childrenSets {
465+
if sts.Spec.Replicas != nil && *sts.Spec.Replicas != sts.Status.ReadyReplicas {
466+
// TODO(schallert): figure out what to do if replicas is not set
467+
c.logger.Info("waiting for statefulset to be ready", zap.String("name", sts.Name), zap.Int32("ready", sts.Status.ReadyReplicas))
468+
return nil
469+
}
470+
}
471+
469472
if err := c.reconcileNamespaces(cluster); err != nil {
470473
c.recorder.WarningEvent(cluster, eventer.ReasonFailedCreate, "failed to create namespace: %s", err)
471474
c.logger.Error("error reconciling namespaces", zap.Error(err))

0 commit comments

Comments
 (0)