Skip to content

Commit

Permalink
[local] Hook in template only nodeinfos provider
Browse files Browse the repository at this point in the history
Hooking it in the less intrusive way we could.
We'll work with upstream for a proper "nodeinfos processor" entrypoint
(and revisit this, depending on the outcome).
  • Loading branch information
bpineau committed Aug 20, 2021
1 parent 8ff05b3 commit b74a7b5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cluster-autoscaler/core/static_autoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ import (
klog "k8s.io/klog/v2"
)

// GetNodeInfosForGroups is a non intrusive entrypoint for nodeinfos provider override
var GetNodeInfosForGroups = core_utils.GetNodeInfosForGroups

const (
// How old the oldest unschedulable pod should be before starting scale up.
unschedulablePodTimeBuffer = 2 * time.Second
Expand Down Expand Up @@ -280,7 +283,7 @@ func (a *StaticAutoscaler) RunOnce(currentTime time.Time) errors.AutoscalerError
return typedErr.AddPrefix("Initialize ClusterSnapshot")
}

nodeInfosForGroups, autoscalerError := core_utils.GetNodeInfosForGroups(
nodeInfosForGroups, autoscalerError := GetNodeInfosForGroups(
readyNodes, a.nodeInfoCache, autoscalingContext.CloudProvider, autoscalingContext.ListerRegistry, daemonsets, autoscalingContext.PredicateChecker, a.ignoredTaints)
if autoscalerError != nil {
klog.Errorf("Failed to get node infos for groups: %v", autoscalerError)
Expand Down
5 changes: 5 additions & 0 deletions cluster-autoscaler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (

"github.com/spf13/pflag"

"k8s.io/autoscaler/cluster-autoscaler/processors/datadog/nodeinfosprovider"
"k8s.io/autoscaler/cluster-autoscaler/processors/datadog/pods"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -341,6 +342,10 @@ func buildAutoscaler() (core.Autoscaler, error) {
metrics.UpdateCPULimitsCores(autoscalingOptions.MinCoresTotal, autoscalingOptions.MaxCoresTotal)
metrics.UpdateMemoryLimitsBytes(autoscalingOptions.MinMemoryTotal, autoscalingOptions.MaxMemoryTotal)

// Datadog only: hook our "ASG template only" nodeInfos provider; not in the cleanest, but in the less
// intrusive and most rebase friendly way we can; until a "nodeInfos provider processor" makes it upstream.
core.GetNodeInfosForGroups = nodeinfosprovider.NewTemplateOnlyNodeInfoProvider().GetNodeInfosForGroups

// Create autoscaler.
return core.NewAutoscaler(opts)
}
Expand Down

0 comments on commit b74a7b5

Please sign in to comment.