From dfc6883819e63a3f75f80be470466ff5ef0c0c55 Mon Sep 17 00:00:00 2001 From: Kubernetes Prow Robot Date: Wed, 12 Jul 2023 09:45:12 -0700 Subject: [PATCH 1/2] Merge pull request #5890 from Bryce-Soghigian/bsoghigian/respecting-bulk-delete fix: setting maxEmptyBulkDelete, and maxScaleDownParallelism to be the same value --- cluster-autoscaler/main.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/cluster-autoscaler/main.go b/cluster-autoscaler/main.go index 9ae3c3ee6d3d..73dbac46850a 100644 --- a/cluster-autoscaler/main.go +++ b/cluster-autoscaler/main.go @@ -207,6 +207,16 @@ var ( maxNodeGroupBinpackingDuration = flag.Duration("max-nodegroup-binpacking-duration", 10*time.Second, "Maximum time that will be spent in binpacking simulation for each NodeGroup.") ) +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 { @@ -224,6 +234,20 @@ func createAutoscalingOptions() config.AutoscalingOptions { if err != nil { klog.Fatalf("Failed to parse flags: %v", err) } + 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, From c74b3c17285ddfa7ca96e843f9f312431fe31b22 Mon Sep 17 00:00:00 2001 From: bsoghigian Date: Tue, 18 Jul 2023 00:50:17 -0700 Subject: [PATCH 2/2] fix: removing reference to parallel drain. This validation does not work, and crashes the autoscaler as parallel drain is not defined in 1.25 --- cluster-autoscaler/main.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/cluster-autoscaler/main.go b/cluster-autoscaler/main.go index 73dbac46850a..470f666bb62c 100644 --- a/cluster-autoscaler/main.go +++ b/cluster-autoscaler/main.go @@ -234,9 +234,6 @@ func createAutoscalingOptions() config.AutoscalingOptions { if err != nil { klog.Fatalf("Failed to parse flags: %v", err) } - 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.