@@ -228,7 +228,7 @@ func (scaleSet *ScaleSet) GetScaleSetSize() (int64, error) {
228228
229229// updateVMSSCapacity invokes virtualMachineScaleSetsClient to update the capacity for VMSS.
230230func (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