From 3a26603300f28eee6a020dc7a661d7ba622def38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20T=C3=B6lle?= Date: Tue, 2 Apr 2024 08:04:26 +0200 Subject: [PATCH] fix: scale up broken for providers not implementing NodeGroup.GetOptions() Properly handle calls to `NodeGroup.GetOptions()` that return `cloudprovider.ErrNotImplemented` in the scale up path. --- cluster-autoscaler/cloudprovider/cloud_provider.go | 2 +- .../core/scaleup/orchestrator/orchestrator.go | 6 +++--- cluster-autoscaler/core/static_autoscaler.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cluster-autoscaler/cloudprovider/cloud_provider.go b/cluster-autoscaler/cloudprovider/cloud_provider.go index 9311a9af1853..43f2a9be2e7c 100644 --- a/cluster-autoscaler/cloudprovider/cloud_provider.go +++ b/cluster-autoscaler/cloudprovider/cloud_provider.go @@ -243,7 +243,7 @@ type NodeGroup interface { // GetOptions returns NodeGroupAutoscalingOptions that should be used for this particular // NodeGroup. Returning a nil will result in using default options. - // Implementation optional. + // Implementation optional. Callers MUST handle `cloudprovider.ErrNotImplemented`. GetOptions(defaults config.NodeGroupAutoscalingOptions) (*config.NodeGroupAutoscalingOptions, error) } diff --git a/cluster-autoscaler/core/scaleup/orchestrator/orchestrator.go b/cluster-autoscaler/core/scaleup/orchestrator/orchestrator.go index 6c75831c12aa..43ba38f76670 100644 --- a/cluster-autoscaler/core/scaleup/orchestrator/orchestrator.go +++ b/cluster-autoscaler/core/scaleup/orchestrator/orchestrator.go @@ -408,7 +408,7 @@ func (o *ScaleUpOrchestrator) filterValidScaleUpNodeGroups( continue } autoscalingOptions, err := nodeGroup.GetOptions(o.autoscalingContext.NodeGroupDefaults) - if err != nil { + if err != nil && err != cloudprovider.ErrNotImplemented { klog.Errorf("Couldn't get autoscaling options for ng: %v", nodeGroup.Id()) } numNodes := 1 @@ -465,7 +465,7 @@ func (o *ScaleUpOrchestrator) ComputeExpansionOption( metrics.UpdateDurationFromStart(metrics.Estimate, estimateStart) autoscalingOptions, err := nodeGroup.GetOptions(o.autoscalingContext.NodeGroupDefaults) - if err != nil { + if err != nil && err != cloudprovider.ErrNotImplemented { klog.Errorf("Failed to get autoscaling options for node group %s: %v", nodeGroup.Id(), err) } if autoscalingOptions != nil && autoscalingOptions.ZeroOrMaxNodeScaling { @@ -662,7 +662,7 @@ func (o *ScaleUpOrchestrator) ComputeSimilarNodeGroups( } autoscalingOptions, err := nodeGroup.GetOptions(o.autoscalingContext.NodeGroupDefaults) - if err != nil { + if err != nil && err != cloudprovider.ErrNotImplemented { klog.Errorf("Failed to get autoscaling options for node group %s: %v", nodeGroup.Id(), err) } if autoscalingOptions != nil && autoscalingOptions.ZeroOrMaxNodeScaling { diff --git a/cluster-autoscaler/core/static_autoscaler.go b/cluster-autoscaler/core/static_autoscaler.go index bbbe77c93ac5..a56ad8e4268f 100644 --- a/cluster-autoscaler/core/static_autoscaler.go +++ b/cluster-autoscaler/core/static_autoscaler.go @@ -794,7 +794,7 @@ func (a *StaticAutoscaler) removeOldUnregisteredNodes(allUnregisteredNodes []clu nodesToDelete := toNodes(unregisteredNodesToDelete) opts, err := nodeGroup.GetOptions(a.NodeGroupDefaults) - if err != nil { + if err != nil && err != cloudprovider.ErrNotImplemented { klog.Warningf("Failed to get node group options for %s: %s", nodeGroupId, err) continue } @@ -874,7 +874,7 @@ func (a *StaticAutoscaler) deleteCreatedNodesWithErrors() (bool, error) { } else { var opts *config.NodeGroupAutoscalingOptions opts, err = nodeGroup.GetOptions(a.NodeGroupDefaults) - if err != nil { + if err != nil && err != cloudprovider.ErrNotImplemented { klog.Warningf("Failed to get node group options for %s: %s", nodeGroupId, err) continue }