Skip to content

Commit

Permalink
operator v1: allow upscale while decom in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
birdayz authored and RafalKorepta committed Jan 2, 2025
1 parent 4321c2f commit fdfe86e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions operator/pkg/resources/statefulset_scale.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,6 @@ const (
func (r *StatefulSetResource) handleScaling(ctx context.Context) error {
log := r.logger.WithName("handleScaling").WithValues("nodepool", r.nodePool.Name)

// This is special - we allow only one decom at a time, ACROSS ALL nodePools. It's not per nodepool.
// if a decommission is already in progress, handle it first. If it's not finished, it will return an error
// which will requeue the reconciliation. We can't (and don't want to) do any further scaling until it's finished.
// handleDecommissionInProgress is supposed to exit with error if a decom is already in progress, so we don't start another decom.
if err := r.handleDecommissionInProgress(ctx, log); err != nil {
return err
}

npStatus := r.getNodePoolStatus()
if npStatus.CurrentReplicas == 0 && ptr.Deref(r.nodePool.Replicas, 0) != 0 && !r.nodePool.Deleted {
// Initialize the currentReplicas field.
Expand All @@ -102,6 +94,14 @@ func (r *StatefulSetResource) handleScaling(ctx context.Context) error {
return r.setCurrentReplicas(ctx, *r.nodePool.Replicas, r.nodePool.Name, r.logger)
}

// This is special - we allow only one decom at a time, ACROSS ALL nodePools. It's not per nodepool.
// if a decommission is already in progress, handle it first. If it's not finished, it will return an error
// which will requeue the reconciliation. We can't (and don't want to) do any further scaling until it's finished.
// handleDecommissionInProgress is supposed to exit with error if a decom is already in progress, so we don't start another decom.
if err := r.handleDecommissionInProgress(ctx, log); err != nil {
return err
}

if ptr.Deref(r.nodePool.Replicas, 0) == npCurrentReplicas {
log.V(logger.DebugLevel).Info("No scaling changes required for this nodepool", "replicas", *r.nodePool.Replicas, "spec replicas", *r.LastObservedState.Spec.Replicas) // No changes to replicas, we do nothing here
return nil
Expand Down

0 comments on commit fdfe86e

Please sign in to comment.