Skip to content

Commit 7821e74

Browse files
authored
Merge pull request kubernetes#3284 from marwanad/use-instance-mutex-to-synchronize-deletions
synchronize scale set instance deletions to avoid 409 conflict errors
2 parents 35901cd + 44ba2ca commit 7821e74

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

cluster-autoscaler/cloudprovider/azure/azure_scale_set.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,13 +441,15 @@ func (scaleSet *ScaleSet) DeleteInstances(instances []*azureRef) error {
441441
ctx, cancel := getContextWithCancel()
442442
defer cancel()
443443
resourceGroup := scaleSet.manager.config.ResourceGroup
444-
klog.V(3).Infof("Calling virtualMachineScaleSetsClient.DeleteInstancesAsync(%v)", requiredIds.InstanceIds)
445444

445+
scaleSet.instanceMutex.Lock()
446+
klog.V(3).Infof("Calling virtualMachineScaleSetsClient.DeleteInstancesAsync(%v)", requiredIds.InstanceIds)
446447
future, rerr := scaleSet.manager.azClient.virtualMachineScaleSetsClient.DeleteInstancesAsync(ctx, resourceGroup, commonAsg.Id(), *requiredIds)
447448
if rerr != nil {
448449
klog.Errorf("virtualMachineScaleSetsClient.DeleteInstancesAsync for instances %v failed: %v", requiredIds.InstanceIds, err)
449450
return rerr.Error()
450451
}
452+
scaleSet.instanceMutex.Unlock()
451453

452454
// Proactively decrement scale set size so that we don't
453455
// go below minimum node count if cache data is stale

0 commit comments

Comments
 (0)