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

cherry-pick: Merge pull request #5890 from Bryce-Soghigian/bsoghigian/respecting-bulk-delete #5966

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
21 changes: 21 additions & 0 deletions cluster-autoscaler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,16 @@ var (
parallelDrain = flag.Bool("parallel-drain", false, "Whether to allow parallel drain of nodes.")
)

func isFlagPassed(name string) bool {
found := false
flag.Visit(func(f *flag.Flag) {
if f.Name == name {
found = true
}
})
return found
}

func createAutoscalingOptions() config.AutoscalingOptions {
minCoresTotal, maxCoresTotal, err := parseMinMaxFlag(*coresTotal)
if err != nil {
Expand All @@ -236,6 +246,17 @@ func createAutoscalingOptions() config.AutoscalingOptions {
if *maxDrainParallelismFlag > 1 && !*parallelDrain {
klog.Fatalf("Invalid configuration, could not use --max-drain-parallelism > 1 if --parallel-drain is false")
}

// in order to avoid inconsistent deletion thresholds for the legacy planner and the new actuator, the max-empty-bulk-delete,
// and max-scale-down-parallelism flags must be set to the same value.
if isFlagPassed("max-empty-bulk-delete") && !isFlagPassed("max-scale-down-parallelism") {
*maxScaleDownParallelismFlag = *maxEmptyBulkDeleteFlag
klog.Warning("The max-empty-bulk-delete flag will be deprecated in k8s version 1.29. Please use max-scale-down-parallelism instead.")
klog.Infof("Setting max-scale-down-parallelism to %d, based on the max-empty-bulk-delete value %d", *maxScaleDownParallelismFlag, *maxEmptyBulkDeleteFlag)
} else if !isFlagPassed("max-empty-bulk-delete") && isFlagPassed("max-scale-down-parallelism") {
*maxEmptyBulkDeleteFlag = *maxScaleDownParallelismFlag
}

return config.AutoscalingOptions{
NodeGroupDefaults: config.NodeGroupAutoscalingOptions{
ScaleDownUtilizationThreshold: *scaleDownUtilizationThreshold,
Expand Down