Skip to content

Commit 2886b31

Browse files
authored
Merge pull request #5967 from Bryce-Soghigian/cp/max-empty-bulk-delete-1.27
Merge pull request #5890 from Bryce-Soghigian/bsoghigian/respecting-bulk-delete
2 parents 5667433 + b9557c7 commit 2886b31

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

cluster-autoscaler/main.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,16 @@ var (
231231
forceDaemonSets = flag.Bool("force-ds", false, "Blocks scale-up of node groups too small for all suitable Daemon Sets pods.")
232232
)
233233

234+
func isFlagPassed(name string) bool {
235+
found := false
236+
flag.Visit(func(f *flag.Flag) {
237+
if f.Name == name {
238+
found = true
239+
}
240+
})
241+
return found
242+
}
243+
234244
func createAutoscalingOptions() config.AutoscalingOptions {
235245
minCoresTotal, maxCoresTotal, err := parseMinMaxFlag(*coresTotal)
236246
if err != nil {
@@ -251,6 +261,17 @@ func createAutoscalingOptions() config.AutoscalingOptions {
251261
if *maxDrainParallelismFlag > 1 && !*parallelDrain {
252262
klog.Fatalf("Invalid configuration, could not use --max-drain-parallelism > 1 if --parallel-drain is false")
253263
}
264+
265+
// in order to avoid inconsistent deletion thresholds for the legacy planner and the new actuator, the max-empty-bulk-delete,
266+
// and max-scale-down-parallelism flags must be set to the same value.
267+
if isFlagPassed("max-empty-bulk-delete") && !isFlagPassed("max-scale-down-parallelism") {
268+
*maxScaleDownParallelismFlag = *maxEmptyBulkDeleteFlag
269+
klog.Warning("The max-empty-bulk-delete flag will be deprecated in k8s version 1.29. Please use max-scale-down-parallelism instead.")
270+
klog.Infof("Setting max-scale-down-parallelism to %d, based on the max-empty-bulk-delete value %d", *maxScaleDownParallelismFlag, *maxEmptyBulkDeleteFlag)
271+
} else if !isFlagPassed("max-empty-bulk-delete") && isFlagPassed("max-scale-down-parallelism") {
272+
*maxEmptyBulkDeleteFlag = *maxScaleDownParallelismFlag
273+
}
274+
254275
return config.AutoscalingOptions{
255276
NodeGroupDefaults: config.NodeGroupAutoscalingOptions{
256277
ScaleDownUtilizationThreshold: *scaleDownUtilizationThreshold,

0 commit comments

Comments
 (0)