Skip to content

Commit

Permalink
If StatefulSet has not caught up yet, do not allow upgrade in any sit…
Browse files Browse the repository at this point in the history
…uation
  • Loading branch information
burmanm committed May 14, 2024
1 parent 2bffea7 commit f5687d6
Showing 1 changed file with 19 additions and 23 deletions.
42 changes: 19 additions & 23 deletions pkg/reconciliation/reconcile_racks.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,25 @@ func (rc *ReconciliationContext) CheckRackPodTemplate() result.ReconcileResult {
}
statefulSet := rc.statefulSets[idx]

// If the statefulset is not updated from previous changes, do not allow modifying it yet
status := statefulSet.Status
if statefulSet.Generation != status.ObservedGeneration ||
status.Replicas != status.ReadyReplicas ||
status.Replicas != status.CurrentReplicas ||
status.Replicas != status.UpdatedReplicas {

logger.Info(
"waiting for upgrade to finish on statefulset",
"statefulset", statefulSet.Name,
"replicas", status.Replicas,
"readyReplicas", status.ReadyReplicas,
"currentReplicas", status.CurrentReplicas,
"updatedReplicas", status.UpdatedReplicas,
)

return result.RequeueSoon(10)
}

desiredSts, err := newStatefulSetForCassandraDatacenter(statefulSet, rackName, dc, int(*statefulSet.Spec.Replicas))

if err != nil {
Expand Down Expand Up @@ -300,29 +319,6 @@ func (rc *ReconciliationContext) CheckRackPodTemplate() result.ReconcileResult {
// we just updated k8s and pods will be knocked out of ready state, so let k8s
// call us back when these changes are done and the new pods are back to ready
return result.Done()
} else {

// the pod template is right, but if any pods don't match it,
// or are missing, we should not move onto the next rack,
// because there's an upgrade in progress

status := statefulSet.Status
if statefulSet.Generation != status.ObservedGeneration ||
status.Replicas != status.ReadyReplicas ||
status.Replicas != status.CurrentReplicas ||
status.Replicas != status.UpdatedReplicas {

logger.Info(
"waiting for upgrade to finish on statefulset",
"statefulset", statefulSet.Name,
"replicas", status.Replicas,
"readyReplicas", status.ReadyReplicas,
"currentReplicas", status.CurrentReplicas,
"updatedReplicas", status.UpdatedReplicas,
)

return result.RequeueSoon(10)
}
}
}

Expand Down

0 comments on commit f5687d6

Please sign in to comment.