Skip to content

Commit 4ac5e85

Browse files
authored
Merge pull request kubernetes#2959 from feiskyer/simple-vmss-put
Ensure only capacity is changed when PUT Azure VMSS
2 parents 9920bdb + d3d4445 commit 4ac5e85

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

cluster-autoscaler/cloudprovider/azure/azure_scale_set.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ func (scaleSet *ScaleSet) GetScaleSetSize() (int64, error) {
228228

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

234234
defer func() {
@@ -241,22 +241,27 @@ func (scaleSet *ScaleSet) updateVMSSCapacity(size int64) {
241241
}
242242
}()
243243

244-
resourceGroup := scaleSet.manager.config.ResourceGroup
245-
op, rerr = scaleSet.getVMSSInfo()
244+
vmssInfo, rerr = scaleSet.getVMSSInfo()
246245
if rerr != nil {
247246
klog.Errorf("Failed to get information for VMSS (%q): %v", scaleSet.Name, rerr)
248247
return
249248
}
250249

250+
// Update the new capacity to cache.
251251
vmssSizeMutex.Lock()
252-
op.Sku.Capacity = &size
252+
vmssInfo.Sku.Capacity = &size
253253
vmssSizeMutex.Unlock()
254-
op.Identity = nil
255-
op.VirtualMachineScaleSetProperties.ProvisioningState = nil
254+
255+
// Compose a new VMSS for updating.
256+
op := compute.VirtualMachineScaleSet{
257+
Name: vmssInfo.Name,
258+
Sku: vmssInfo.Sku,
259+
Location: vmssInfo.Location,
260+
}
256261
ctx, cancel := getContextWithCancel()
257262
defer cancel()
258263
klog.V(3).Infof("Waiting for virtualMachineScaleSetsClient.CreateOrUpdate(%s)", scaleSet.Name)
259-
rerr = scaleSet.manager.azClient.virtualMachineScaleSetsClient.CreateOrUpdate(ctx, resourceGroup, scaleSet.Name, op)
264+
rerr = scaleSet.manager.azClient.virtualMachineScaleSetsClient.CreateOrUpdate(ctx, scaleSet.manager.config.ResourceGroup, scaleSet.Name, op)
260265
if rerr != nil {
261266
klog.Errorf("virtualMachineScaleSetsClient.CreateOrUpdate for scale set %q failed: %v", scaleSet.Name, rerr)
262267
return

0 commit comments

Comments
 (0)