-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement GetOptions for Azure #4237
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ import ( | |
|
||
"github.com/Azure/go-autorest/autorest/azure" | ||
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider" | ||
"k8s.io/autoscaler/cluster-autoscaler/config" | ||
"k8s.io/autoscaler/cluster-autoscaler/config/dynamic" | ||
klog "k8s.io/klog/v2" | ||
) | ||
|
@@ -246,6 +247,29 @@ func (m *AzureManager) GetNodeGroupForInstance(instance *azureRef) (cloudprovide | |
return m.azureCache.FindForInstance(instance, m.config.VMType) | ||
} | ||
|
||
// GetScaleSetOptions parse options extracted from VMSS tags and merges them with provided defaults | ||
func (m *AzureManager) GetScaleSetOptions(scaleSetName string, defaults config.NodeGroupAutoscalingOptions) *config.NodeGroupAutoscalingOptions { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we propagate an error back from here? How are you handling those errors for other cloudprovider implementations? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Intent is not to impact operations on errors, but make them visible and auditable. Missing options tags is just fine (and likely). Likewise for incomplete/partial tags set. We log and ignore bogus (or similar-looking yet different, etc) tag values. That's similar for aws and gce cloudproviders. |
||
options := m.azureCache.getAutoscalingOptions(azureRef{Name: scaleSetName}) | ||
if options == nil || len(options) == 0 { | ||
return &defaults | ||
} | ||
|
||
if opt, ok := getFloat64Option(options, scaleSetName, config.DefaultScaleDownUtilizationThresholdKey); ok { | ||
defaults.ScaleDownUtilizationThreshold = opt | ||
} | ||
if opt, ok := getFloat64Option(options, scaleSetName, config.DefaultScaleDownGpuUtilizationThresholdKey); ok { | ||
defaults.ScaleDownGpuUtilizationThreshold = opt | ||
} | ||
if opt, ok := getDurationOption(options, scaleSetName, config.DefaultScaleDownUnneededTimeKey); ok { | ||
defaults.ScaleDownUnneededTime = opt | ||
} | ||
if opt, ok := getDurationOption(options, scaleSetName, config.DefaultScaleDownUnreadyTimeKey); ok { | ||
defaults.ScaleDownUnreadyTime = opt | ||
} | ||
|
||
return &defaults | ||
} | ||
|
||
// Cleanup the cache. | ||
func (m *AzureManager) Cleanup() { | ||
m.azureCache.Cleanup() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: should this be done in the above if check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're rebuilding that option cache from scratch (
newAutoscalingOptions
is empty before that loop) so we have to store both changed and previously known options there.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh gotcha