Skip to content

Commit

Permalink
Create missing statefulsets before waiting for ready (#227)
Browse files Browse the repository at this point in the history
Co-authored-by: Matt Schallert <[email protected]>
  • Loading branch information
robskillington and schallert authored Jul 16, 2020
1 parent a052641 commit 53f16ed
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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))
Expand Down

0 comments on commit 53f16ed

Please sign in to comment.