Refactor autoscaler.go and static_autoscalar.go to move declaration of the NodeDeletion option to main.go
This commit is contained in:
parent
b569db410f
commit
0f8502c623
|
|
@ -31,6 +31,7 @@ import (
|
|||
"k8s.io/autoscaler/cluster-autoscaler/expander"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/expander/factory"
|
||||
ca_processors "k8s.io/autoscaler/cluster-autoscaler/processors"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/simulator"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/simulator/clustersnapshot"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/simulator/predicatechecker"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/utils/backoff"
|
||||
|
|
@ -54,6 +55,7 @@ type AutoscalerOptions struct {
|
|||
DebuggingSnapshotter debuggingsnapshot.DebuggingSnapshotter
|
||||
RemainingPdbTracker pdb.RemainingPdbTracker
|
||||
ScaleUpOrchestrator scaleup.Orchestrator
|
||||
DeleteOptions simulator.NodeDeleteOptions
|
||||
}
|
||||
|
||||
// Autoscaler is the main component of CA which scales up/down node groups according to its configuration
|
||||
|
|
@ -85,7 +87,8 @@ func NewAutoscaler(opts AutoscalerOptions) (Autoscaler, errors.AutoscalerError)
|
|||
opts.Backoff,
|
||||
opts.DebuggingSnapshotter,
|
||||
opts.RemainingPdbTracker,
|
||||
opts.ScaleUpOrchestrator), nil
|
||||
opts.ScaleUpOrchestrator,
|
||||
opts.DeleteOptions), nil
|
||||
}
|
||||
|
||||
// Initialize default options if not provided.
|
||||
|
|
|
|||
|
|
@ -141,7 +141,8 @@ func NewStaticAutoscaler(
|
|||
backoff backoff.Backoff,
|
||||
debuggingSnapshotter debuggingsnapshot.DebuggingSnapshotter,
|
||||
remainingPdbTracker pdb.RemainingPdbTracker,
|
||||
scaleUpOrchestrator scaleup.Orchestrator) *StaticAutoscaler {
|
||||
scaleUpOrchestrator scaleup.Orchestrator,
|
||||
deleteOptions simulator.NodeDeleteOptions) *StaticAutoscaler {
|
||||
|
||||
clusterStateConfig := clusterstate.ClusterStateRegistryConfig{
|
||||
MaxTotalUnreadyPercentage: opts.MaxTotalUnreadyPercentage,
|
||||
|
|
@ -166,8 +167,6 @@ func NewStaticAutoscaler(
|
|||
clusterStateRegistry.RegisterProviders(providers.NewDefaultMaxNodeProvisionTimeProvider(autoscalingContext, processors.NodeGroupConfigProcessor))
|
||||
processors.ScaleDownCandidatesNotifier.Register(clusterStateRegistry)
|
||||
|
||||
deleteOptions := simulator.NewNodeDeleteOptions(opts)
|
||||
|
||||
// TODO: Populate the ScaleDownActuator/Planner fields in AutoscalingContext
|
||||
// during the struct creation rather than here.
|
||||
ndt := deletiontracker.NewNodeDeletionTracker(0 * time.Second)
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import (
|
|||
"time"
|
||||
|
||||
"k8s.io/autoscaler/cluster-autoscaler/debuggingsnapshot"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/simulator"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/simulator/predicatechecker"
|
||||
|
||||
"github.com/spf13/pflag"
|
||||
|
|
@ -404,6 +405,7 @@ func buildAutoscaler(debuggingSnapshotter debuggingsnapshot.DebuggingSnapshotter
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
deleteOptions := simulator.NewNodeDeleteOptions(autoscalingOptions)
|
||||
|
||||
opts := core.AutoscalerOptions{
|
||||
AutoscalingOptions: autoscalingOptions,
|
||||
|
|
@ -412,6 +414,7 @@ func buildAutoscaler(debuggingSnapshotter debuggingsnapshot.DebuggingSnapshotter
|
|||
EventsKubeClient: eventsKubeClient,
|
||||
DebuggingSnapshotter: debuggingSnapshotter,
|
||||
PredicateChecker: predicateChecker,
|
||||
DeleteOptions: deleteOptions,
|
||||
}
|
||||
|
||||
opts.Processors = ca_processors.DefaultProcessors()
|
||||
|
|
@ -421,7 +424,7 @@ func buildAutoscaler(debuggingSnapshotter debuggingsnapshot.DebuggingSnapshotter
|
|||
if autoscalingOptions.ParallelDrain {
|
||||
sdCandidatesSorting := previouscandidates.NewPreviousCandidates()
|
||||
scaleDownCandidatesComparers = []scaledowncandidates.CandidatesComparer{
|
||||
emptycandidates.NewEmptySortingProcessor(&autoscalingOptions, emptycandidates.NewNodeInfoGetter(opts.ClusterSnapshot)),
|
||||
emptycandidates.NewEmptySortingProcessor(emptycandidates.NewNodeInfoGetter(opts.ClusterSnapshot), deleteOptions),
|
||||
sdCandidatesSorting,
|
||||
}
|
||||
opts.Processors.ScaleDownCandidatesNotifier.Register(sdCandidatesSorting)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import (
|
|||
"time"
|
||||
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/config"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/simulator"
|
||||
"k8s.io/autoscaler/cluster-autoscaler/simulator/clustersnapshot"
|
||||
schedulerframework "k8s.io/kubernetes/pkg/scheduler/framework"
|
||||
|
|
@ -50,8 +49,7 @@ type EmptySorting struct {
|
|||
}
|
||||
|
||||
// NewEmptySortingProcessor return EmptySorting struct.
|
||||
func NewEmptySortingProcessor(opts *config.AutoscalingOptions, n nodeInfoGetter) *EmptySorting {
|
||||
deleteOptions := simulator.NewNodeDeleteOptions(*opts)
|
||||
func NewEmptySortingProcessor(n nodeInfoGetter, deleteOptions simulator.NodeDeleteOptions) *EmptySorting {
|
||||
return &EmptySorting{n, deleteOptions}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue