From ab4c5cb8c76d14b8504b18dfc6cf56e963159679 Mon Sep 17 00:00:00 2001 From: Artem Minyaylov Date: Thu, 19 Oct 2023 15:55:34 +0000 Subject: [PATCH] Initialize default drainability rules --- cluster-autoscaler/core/autoscaler.go | 3 +++ cluster-autoscaler/main.go | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cluster-autoscaler/core/autoscaler.go b/cluster-autoscaler/core/autoscaler.go index 29d4b841b8ba..f0baf8cc51f7 100644 --- a/cluster-autoscaler/core/autoscaler.go +++ b/cluster-autoscaler/core/autoscaler.go @@ -144,6 +144,9 @@ func initializeDefaultOptions(opts *AutoscalerOptions) error { opts.Backoff = backoff.NewIdBasedExponentialBackoff(opts.InitialNodeGroupBackoffDuration, opts.MaxNodeGroupBackoffDuration, opts.NodeGroupBackoffResetTimeout) } + if opts.DrainabilityRules == nil { + opts.DrainabilityRules = rules.Default(opts.DeleteOptions) + } return nil } diff --git a/cluster-autoscaler/main.go b/cluster-autoscaler/main.go index 5f879522670a..5276b97c5658 100644 --- a/cluster-autoscaler/main.go +++ b/cluster-autoscaler/main.go @@ -462,6 +462,7 @@ func buildAutoscaler(debuggingSnapshotter debuggingsnapshot.DebuggingSnapshotter return nil, err } deleteOptions := options.NewNodeDeleteOptions(autoscalingOptions) + drainabilityRules := rules.Default(deleteOptions) opts := core.AutoscalerOptions{ AutoscalingOptions: autoscalingOptions, @@ -472,6 +473,7 @@ func buildAutoscaler(debuggingSnapshotter debuggingsnapshot.DebuggingSnapshotter DebuggingSnapshotter: debuggingSnapshotter, PredicateChecker: predicateChecker, DeleteOptions: deleteOptions, + DrainabilityRules: drainabilityRules, } opts.Processors = ca_processors.DefaultProcessors(autoscalingOptions) @@ -481,7 +483,7 @@ func buildAutoscaler(debuggingSnapshotter debuggingsnapshot.DebuggingSnapshotter if autoscalingOptions.ParallelDrain { sdCandidatesSorting := previouscandidates.NewPreviousCandidates() scaleDownCandidatesComparers = []scaledowncandidates.CandidatesComparer{ - emptycandidates.NewEmptySortingProcessor(emptycandidates.NewNodeInfoGetter(opts.ClusterSnapshot), deleteOptions, rules.Default(deleteOptions)), + emptycandidates.NewEmptySortingProcessor(emptycandidates.NewNodeInfoGetter(opts.ClusterSnapshot), deleteOptions, drainabilityRules), sdCandidatesSorting, } opts.Processors.ScaleDownCandidatesNotifier.Register(sdCandidatesSorting)