Skip to content

Commit

Permalink
Remove the NodeInfoProcessor builder
Browse files Browse the repository at this point in the history
  • Loading branch information
clamoriniere committed Jun 30, 2021
1 parent 4a833e6 commit 672fe3b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 72 deletions.
4 changes: 2 additions & 2 deletions cluster-autoscaler/config/autoscaling_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,6 @@ type AutoscalingOptions struct {
DaemonSetEvictionForEmptyNodes bool
// User agent to use for HTTP calls.
UserAgent string
// NodeInfoProcessorName sets the type of the NodeInfo processor. Allowed value: podtemplates.
NodeInfoProcessorName string
// NodeInfoProcessorPodTemplates Enable or disable the NodeInfoProcessor PodTemplate
NodeInfoProcessorPodTemplates bool
}
17 changes: 5 additions & 12 deletions cluster-autoscaler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ import (
"k8s.io/autoscaler/cluster-autoscaler/metrics"
ca_processors "k8s.io/autoscaler/cluster-autoscaler/processors"
"k8s.io/autoscaler/cluster-autoscaler/processors/nodegroupset"
nodeinfobuilder "k8s.io/autoscaler/cluster-autoscaler/processors/nodeinfos/builder"
_ "k8s.io/autoscaler/cluster-autoscaler/processors/nodeinfos/podtemplates"
"k8s.io/autoscaler/cluster-autoscaler/processors/nodeinfos/podtemplates"
"k8s.io/autoscaler/cluster-autoscaler/simulator"
"k8s.io/autoscaler/cluster-autoscaler/utils/errors"
kube_util "k8s.io/autoscaler/cluster-autoscaler/utils/kubernetes"
Expand Down Expand Up @@ -181,7 +180,7 @@ var (
cordonNodeBeforeTerminate = flag.Bool("cordon-node-before-terminating", false, "Should CA cordon nodes before terminating during downscale process")
daemonSetEvictionForEmptyNodes = flag.Bool("daemonset-eviction-for-empty-nodes", false, "DaemonSet pods will be gracefully terminated from empty nodes")
userAgent = flag.String("user-agent", "cluster-autoscaler", "User agent used for HTTP calls.")
nodeInfoProcessorName = flag.String("node-info-processor", "", "node-info processor type. Available values: ["+strings.Join(nodeinfobuilder.GetAvailableNodeInfoProcessors(), ",")+"]")
nodeInfoProcessorPodTemplates = flag.Bool("node-info-processor-podtemplate", false, "Enable PodTemplate NodeInfoProcessor to consider specific PodTemplate as DaemonSet")
)

func createAutoscalingOptions() config.AutoscalingOptions {
Expand Down Expand Up @@ -258,7 +257,7 @@ func createAutoscalingOptions() config.AutoscalingOptions {
CordonNodeBeforeTerminate: *cordonNodeBeforeTerminate,
DaemonSetEvictionForEmptyNodes: *daemonSetEvictionForEmptyNodes,
UserAgent: *userAgent,
NodeInfoProcessorName: *nodeInfoProcessorName,
NodeInfoProcessorPodTemplates: *nodeInfoProcessorPodTemplates,
}
}

Expand Down Expand Up @@ -333,14 +332,8 @@ func buildAutoscaler() (core.Autoscaler, error) {
Comparator: nodeInfoComparatorBuilder(autoscalingOptions.BalancingExtraIgnoredLabels),
}

// Enable a NodeInfoProcessorName if requested.
if autoscalingOptions.NodeInfoProcessorName != "" {
processor, err := nodeinfobuilder.Build(&opts)
if err != nil {
klog.Errorf("Unable to instantiate the requested NodeInfoProcessor, err: %w", err)
} else {
opts.Processors.NodeInfoProcessor = processor
}
if autoscalingOptions.NodeInfoProcessorPodTemplates {
opts.Processors.NodeInfoProcessor = podtemplates.NewNodeInfoWithPodTemplateProcessor(&opts)
}

// These metrics should be published only once.
Expand Down
51 changes: 0 additions & 51 deletions cluster-autoscaler/processors/nodeinfos/builder/build.go

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import (
ca_context "k8s.io/autoscaler/cluster-autoscaler/context"
"k8s.io/autoscaler/cluster-autoscaler/core"
"k8s.io/autoscaler/cluster-autoscaler/processors/nodeinfos"
"k8s.io/autoscaler/cluster-autoscaler/processors/nodeinfos/builder"
"k8s.io/autoscaler/cluster-autoscaler/simulator"
"k8s.io/autoscaler/cluster-autoscaler/utils/errors"
schedulerframework "k8s.io/kubernetes/pkg/scheduler/framework"
Expand All @@ -47,14 +46,8 @@ const (
PodTemplateDaemonSetLabelKey = "cluster-autoscaler.kubernetes.io/daemonset-pod"
// PodTemplateDaemonSetLabelValueTrue use as PodTemplateDaemonSetLabelKey label value.
PodTemplateDaemonSetLabelValueTrue = "true"
// processorsName use to identify the PodTemplate NodeInfoProcessor
processorName = "podtemplates"
)

func init() {
builder.Register(processorName, NewNodeInfoWithPodTemplateProcessor)
}

// NewNodeInfoWithPodTemplateProcessor returns a default instance of NodeInfoProcessor.
func NewNodeInfoWithPodTemplateProcessor(opts *core.AutoscalerOptions) nodeinfos.NodeInfoProcessor {
internalContext, cancelFunc := context.WithCancel(context.Background())
Expand Down

0 comments on commit 672fe3b

Please sign in to comment.