Skip to content

Commit

Permalink
Merge pull request #5388 from BigDarkClown/predicate_checker
Browse files Browse the repository at this point in the history
Move PredicateChecker initialization before processors initialization
  • Loading branch information
k8s-ci-robot authored Dec 27, 2022
2 parents 43a8c00 + 62c68e1 commit 94681ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
8 changes: 0 additions & 8 deletions cluster-autoscaler/core/autoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
7 changes: 7 additions & 0 deletions cluster-autoscaler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"time"

"k8s.io/autoscaler/cluster-autoscaler/debuggingsnapshot"
"k8s.io/autoscaler/cluster-autoscaler/simulator/predicatechecker"

"github.com/spf13/pflag"

Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 94681ed

Please sign in to comment.