From 53f16ed62302eb02185c7fc8d458c10fcc5c9ff9 Mon Sep 17 00:00:00 2001 From: Rob Skillington Date: Thu, 16 Jul 2020 11:32:16 -0400 Subject: [PATCH] Create missing statefulsets before waiting for ready (#227) Co-authored-by: Matt Schallert --- pkg/controller/controller.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index bd21bdd9..f47d38c3 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -436,13 +436,6 @@ func (c *M3DBController) handleClusterUpdate(cluster *myspec.M3DBCluster) error childrenSetsByName := make(map[string]*appsv1.StatefulSet) for _, sts := range childrenSets { childrenSetsByName[sts.Name] = sts - // if any of the statefulsets aren't ready, wait until they are as we'll get - // another event (ready == bootstrapped) - if sts.Spec.Replicas != nil && *sts.Spec.Replicas != sts.Status.ReadyReplicas { - // TODO(schallert): figure out what to do if replicas is not set - c.logger.Info("waiting for statefulset to be ready", zap.String("name", sts.Name), zap.Int32("ready", sts.Status.ReadyReplicas)) - return nil - } } // 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 } } + // If any of the statefulsets aren't ready, wait until they are as we'll get + // another event (ready == bootstrapped) + for _, sts := range childrenSets { + if sts.Spec.Replicas != nil && *sts.Spec.Replicas != sts.Status.ReadyReplicas { + // TODO(schallert): figure out what to do if replicas is not set + c.logger.Info("waiting for statefulset to be ready", zap.String("name", sts.Name), zap.Int32("ready", sts.Status.ReadyReplicas)) + return nil + } + } + if err := c.reconcileNamespaces(cluster); err != nil { c.recorder.WarningEvent(cluster, eventer.ReasonFailedCreate, "failed to create namespace: %s", err) c.logger.Error("error reconciling namespaces", zap.Error(err))