Skip to content

Commit e250076

Browse files
committed
reduce instance mutex lock scope since its used by the Nodes() call to refresh cache
1 parent da47042 commit e250076

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

cluster-autoscaler/cloudprovider/azure/azure_scale_set.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,6 @@ func (scaleSet *ScaleSet) DeleteInstances(instances []*azureRef) error {
411411
return err
412412
}
413413

414-
scaleSet.instanceMutex.Lock()
415-
defer scaleSet.instanceMutex.Unlock()
416-
417414
instanceIDs := []string{}
418415
for _, instance := range instances {
419416
asg, err := scaleSet.manager.GetAsgForInstance(instance)
@@ -425,10 +422,12 @@ func (scaleSet *ScaleSet) DeleteInstances(instances []*azureRef) error {
425422
return fmt.Errorf("cannot delete instance (%s) which don't belong to the same Scale Set (%q)", instance.Name, commonAsg)
426423
}
427424

425+
scaleSet.instanceMutex.Lock()
428426
if cpi, found := scaleSet.getInstanceByProviderID(instance.Name); found && cpi.Status != nil && cpi.Status.State == cloudprovider.InstanceDeleting {
429427
klog.V(3).Infof("Skipping deleting instance %s as its current state is deleting", instance.Name)
430428
continue
431429
}
430+
scaleSet.instanceMutex.Unlock()
432431

433432
instanceID, err := getLastSegment(instance.Name)
434433
if err != nil {

0 commit comments

Comments
 (0)