Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

operator v1: allow upscale while decom in progress #333

Merged
merged 1 commit into from
Jan 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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