Skip to content

Commit

Permalink
Check for non-updated replicas during down-scale in zoneTracker (#141)
Browse files Browse the repository at this point in the history
Signed-off-by: JordanRushing <[email protected]>
  • Loading branch information
JordanRushing authored Jun 5, 2024
1 parent 3b0040a commit 0b18d84
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/admission/zone_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,19 @@ func (zt *zoneTracker) prepareDownscale(ctx context.Context, l log.Logger, ar v1
level.Warn(logger).Log("msg", msg, "err", err)
return deny(msg)
}
foundSts, err = findStatefulSetWithNonUpdatedReplicas(ctx, api, ar.Request.Namespace, stsList, ar.Request.Name)
if err != nil {
msg := fmt.Sprintf("downscale of %s/%s in %s from %d to %d replicas is not allowed because an error occurred while checking whether StatefulSets have non-updated replicas",
ar.Request.Resource.Resource, ar.Request.Name, ar.Request.Namespace, *oldInfo.replicas, *newInfo.replicas)
level.Warn(logger).Log("msg", msg, "err", err)
return deny(msg)
}
if foundSts != nil {
msg := fmt.Sprintf("downscale of %s/%s in %s from %d to %d replicas is not allowed because statefulset %v has %d non-updated replicas and %d non-ready replicas",
ar.Request.Resource.Resource, ar.Request.Name, ar.Request.Namespace, *oldInfo.replicas, *newInfo.replicas, foundSts.name, foundSts.nonUpdatedReplicas, foundSts.nonReadyReplicas)
level.Warn(logger).Log("msg", msg)
return deny(msg)
}
}

// Since it's a downscale, check if the resource has the label that indicates it needs to be prepared to be downscaled.
Expand Down

0 comments on commit 0b18d84

Please sign in to comment.