File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed
cluster-autoscaler/cloudprovider/azure Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -414,12 +414,10 @@ func (scaleSet *ScaleSet) DeleteInstances(instances []*azureRef) error {
414414 return fmt .Errorf ("cannot delete instance (%s) which don't belong to the same Scale Set (%q)" , instance .Name , commonAsg )
415415 }
416416
417- scaleSet .instanceMutex .Lock ()
418417 if cpi , found := scaleSet .getInstanceByProviderID (instance .Name ); found && cpi .Status != nil && cpi .Status .State == cloudprovider .InstanceDeleting {
419418 klog .V (3 ).Infof ("Skipping deleting instance %s as its current state is deleting" , instance .Name )
420419 continue
421420 }
422- scaleSet .instanceMutex .Unlock ()
423421
424422 instanceID , err := getLastSegment (instance .Name )
425423 if err != nil {
@@ -730,6 +728,8 @@ func buildInstanceCache(vms []compute.VirtualMachineScaleSetVM) []cloudprovider.
730728}
731729
732730func (scaleSet * ScaleSet ) getInstanceByProviderID (providerID string ) (cloudprovider.Instance , bool ) {
731+ scaleSet .instanceMutex .Lock ()
732+ defer scaleSet .instanceMutex .Unlock ()
733733 for _ , instance := range scaleSet .instanceCache {
734734 if instance .Id == providerID {
735735 return instance , true
You can’t perform that action at this time.
0 commit comments