Move PredicateChecker initialization before processors initialization

This commit is contained in:
Bartłomiej Wróblewski 2022-12-27 15:01:44 +00:00
parent 43a8c00146
commit 62c68e1280
2 changed files with 7 additions and 8 deletions

View File

@ -90,14 +90,6 @@ func initializeDefaultOptions(opts *AutoscalerOptions) error {
if opts.AutoscalingKubeClients == nil { if opts.AutoscalingKubeClients == nil {
opts.AutoscalingKubeClients = context.NewAutoscalingKubeClients(opts.AutoscalingOptions, opts.KubeClient, opts.EventsKubeClient) 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 { if opts.ClusterSnapshot == nil {
opts.ClusterSnapshot = clustersnapshot.NewBasicClusterSnapshot() opts.ClusterSnapshot = clustersnapshot.NewBasicClusterSnapshot()
} }

View File

@ -30,6 +30,7 @@ import (
"time" "time"
"k8s.io/autoscaler/cluster-autoscaler/debuggingsnapshot" "k8s.io/autoscaler/cluster-autoscaler/debuggingsnapshot"
"k8s.io/autoscaler/cluster-autoscaler/simulator/predicatechecker"
"github.com/spf13/pflag" "github.com/spf13/pflag"
@ -365,12 +366,18 @@ func buildAutoscaler(debuggingSnapshotter debuggingsnapshot.DebuggingSnapshotter
kubeClient := createKubeClient(getKubeConfig()) kubeClient := createKubeClient(getKubeConfig())
eventsKubeClient := createKubeClient(getKubeConfig()) eventsKubeClient := createKubeClient(getKubeConfig())
predicateChecker, err := predicatechecker.NewSchedulerBasedPredicateChecker(kubeClient, make(chan struct{}))
if err != nil {
return nil, err
}
opts := core.AutoscalerOptions{ opts := core.AutoscalerOptions{
AutoscalingOptions: autoscalingOptions, AutoscalingOptions: autoscalingOptions,
ClusterSnapshot: clustersnapshot.NewDeltaClusterSnapshot(), ClusterSnapshot: clustersnapshot.NewDeltaClusterSnapshot(),
KubeClient: kubeClient, KubeClient: kubeClient,
EventsKubeClient: eventsKubeClient, EventsKubeClient: eventsKubeClient,
DebuggingSnapshotter: debuggingSnapshotter, DebuggingSnapshotter: debuggingSnapshotter,
PredicateChecker: predicateChecker,
} }
opts.Processors = ca_processors.DefaultProcessors() opts.Processors = ca_processors.DefaultProcessors()