Skip to content

Commit

Permalink
refactor: use a limiting interface in actuator in place of `NodeGroup…
Browse files Browse the repository at this point in the history
…ConfigProcessor` interface

- to limit the functions that can be used
- since we need it only for `GetIgnoreDaemonSetsUtilization`
Signed-off-by: vadasambar <[email protected]>
  • Loading branch information
vadasambar committed Apr 11, 2023
1 parent b632d12 commit 24babe2
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions cluster-autoscaler/core/scaledown/actuation/actuator.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
"k8s.io/autoscaler/cluster-autoscaler/core/utils"
"k8s.io/autoscaler/cluster-autoscaler/metrics"
"k8s.io/autoscaler/cluster-autoscaler/processors"
"k8s.io/autoscaler/cluster-autoscaler/processors/nodegroupconfig"
"k8s.io/autoscaler/cluster-autoscaler/simulator"
"k8s.io/autoscaler/cluster-autoscaler/simulator/clustersnapshot"
"k8s.io/autoscaler/cluster-autoscaler/simulator/utilization"
Expand All @@ -53,7 +52,14 @@ type Actuator struct {
nodeDeletionBatcher *NodeDeletionBatcher
evictor Evictor
deleteOptions simulator.NodeDeleteOptions
nodeConfigProcessor nodegroupconfig.NodeGroupConfigProcessor
configGetter actuatorNodeGroupConfigGetter
}

// actuatorNodeGroupConfigGetter is an interface to limit the functions that can be used
// from NodeGroupConfigProcessor interface
type actuatorNodeGroupConfigGetter interface {
// GetIgnoreDaemonSetsUtilization returns IgnoreDaemonSetsUtilization value that should be used for a given NodeGroup.
GetIgnoreDaemonSetsUtilization(context *context.AutoscalingContext, nodeGroup cloudprovider.NodeGroup) (bool, error)
}

// NewActuator returns a new instance of Actuator.
Expand All @@ -66,7 +72,7 @@ func NewActuator(ctx *context.AutoscalingContext, csr *clusterstate.ClusterState
nodeDeletionBatcher: nbd,
evictor: NewDefaultEvictor(deleteOptions, ndt),
deleteOptions: deleteOptions,
nodeConfigProcessor: processors.NodeGroupConfigProcessor,
configGetter: processors.NodeGroupConfigProcessor,
}
}

Expand Down Expand Up @@ -311,7 +317,7 @@ func (a *Actuator) scaleDownNodeToReport(node *apiv1.Node, drain bool) (*status.
return nil, err
}

ignoreDaemonSetsUtilization, err := a.nodeConfigProcessor.GetIgnoreDaemonSetsUtilization(a.ctx, nodeGroup)
ignoreDaemonSetsUtilization, err := a.configGetter.GetIgnoreDaemonSetsUtilization(a.ctx, nodeGroup)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 24babe2

Please sign in to comment.