From 7fef308aeb867baad4b573c2f778a23fbff9d9f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Wr=C3=B3blewski?= Date: Tue, 27 Dec 2022 15:01:44 +0000 Subject: [PATCH] Move PredicateChecker initialization before processors initialization --- cluster-autoscaler/core/autoscaler.go | 8 -------- cluster-autoscaler/main.go | 7 +++++++ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/cluster-autoscaler/core/autoscaler.go b/cluster-autoscaler/core/autoscaler.go index 523642b1018b..f6084ec46ad1 100644 --- a/cluster-autoscaler/core/autoscaler.go +++ b/cluster-autoscaler/core/autoscaler.go @@ -90,14 +90,6 @@ func initializeDefaultOptions(opts *AutoscalerOptions) error { if opts.AutoscalingKubeClients == nil { opts.AutoscalingKubeClients = context.NewAutoscalingKubeClients(opts.AutoscalingOptions, opts.KubeClient, opts.EventsKubeClient) } - if opts.PredicateChecker == nil { - predicateCheckerStopChannel := make(chan struct{}) - predicateChecker, err := predicatechecker.NewSchedulerBasedPredicateChecker(opts.KubeClient, predicateCheckerStopChannel) - if err != nil { - return err - } - opts.PredicateChecker = predicateChecker - } if opts.ClusterSnapshot == nil { opts.ClusterSnapshot = clustersnapshot.NewBasicClusterSnapshot() } diff --git a/cluster-autoscaler/main.go b/cluster-autoscaler/main.go index 4b749546fcc9..22e1d9460098 100644 --- a/cluster-autoscaler/main.go +++ b/cluster-autoscaler/main.go @@ -30,6 +30,7 @@ import ( "time" "k8s.io/autoscaler/cluster-autoscaler/debuggingsnapshot" + "k8s.io/autoscaler/cluster-autoscaler/simulator/predicatechecker" "github.com/spf13/pflag" @@ -365,12 +366,18 @@ func buildAutoscaler(debuggingSnapshotter debuggingsnapshot.DebuggingSnapshotter kubeClient := createKubeClient(getKubeConfig()) eventsKubeClient := createKubeClient(getKubeConfig()) + predicateChecker, err := predicatechecker.NewSchedulerBasedPredicateChecker(kubeClient, make(chan struct{})) + if err != nil { + return nil, err + } + opts := core.AutoscalerOptions{ AutoscalingOptions: autoscalingOptions, ClusterSnapshot: clustersnapshot.NewDeltaClusterSnapshot(), KubeClient: kubeClient, EventsKubeClient: eventsKubeClient, DebuggingSnapshotter: debuggingSnapshotter, + PredicateChecker: predicateChecker, } opts.Processors = ca_processors.DefaultProcessors()