Skip to content
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

1.18: Ensure only capacity is changed when PUT Azure VMSS #2960

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions cluster-autoscaler/cloudprovider/azure/azure_scale_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func (scaleSet *ScaleSet) GetScaleSetSize() (int64, error) {

// updateVMSSCapacity invokes virtualMachineScaleSetsClient to update the capacity for VMSS.
func (scaleSet *ScaleSet) updateVMSSCapacity(size int64) {
var op compute.VirtualMachineScaleSet
var vmssInfo compute.VirtualMachineScaleSet
var rerr *retry.Error

defer func() {
Expand All @@ -241,22 +241,27 @@ func (scaleSet *ScaleSet) updateVMSSCapacity(size int64) {
}
}()

resourceGroup := scaleSet.manager.config.ResourceGroup
op, rerr = scaleSet.getVMSSInfo()
vmssInfo, rerr = scaleSet.getVMSSInfo()
if rerr != nil {
klog.Errorf("Failed to get information for VMSS (%q): %v", scaleSet.Name, rerr)
return
}

// Update the new capacity to cache.
vmssSizeMutex.Lock()
op.Sku.Capacity = &size
vmssInfo.Sku.Capacity = &size
vmssSizeMutex.Unlock()
op.Identity = nil
op.VirtualMachineScaleSetProperties.ProvisioningState = nil

// Compose a new VMSS for updating.
op := compute.VirtualMachineScaleSet{
Name: vmssInfo.Name,
Sku: vmssInfo.Sku,
Location: vmssInfo.Location,
}
ctx, cancel := getContextWithCancel()
defer cancel()
klog.V(3).Infof("Waiting for virtualMachineScaleSetsClient.CreateOrUpdate(%s)", scaleSet.Name)
rerr = scaleSet.manager.azClient.virtualMachineScaleSetsClient.CreateOrUpdate(ctx, resourceGroup, scaleSet.Name, op)
rerr = scaleSet.manager.azClient.virtualMachineScaleSetsClient.CreateOrUpdate(ctx, scaleSet.manager.config.ResourceGroup, scaleSet.Name, op)
if rerr != nil {
klog.Errorf("virtualMachineScaleSetsClient.CreateOrUpdate for scale set %q failed: %v", scaleSet.Name, rerr)
return
Expand Down