Merge pull request #3261 from marwanad/reduce-lock-scope
Reduce instance lock scope in scale sets
This commit is contained in:
commit
385b73d70b
|
|
@ -228,14 +228,6 @@ func (scaleSet *ScaleSet) GetScaleSetSize() (int64, error) {
|
|||
}
|
||||
|
||||
func (scaleSet *ScaleSet) waitForDeleteInstances(future *azure.Future, requiredIds *compute.VirtualMachineScaleSetVMInstanceRequiredIDs) {
|
||||
var err error
|
||||
|
||||
defer func() {
|
||||
if err != nil {
|
||||
klog.Errorf("Failed to delete instances %v", requiredIds.InstanceIds)
|
||||
}
|
||||
}()
|
||||
|
||||
ctx, cancel := getContextWithCancel()
|
||||
defer cancel()
|
||||
|
||||
|
|
@ -411,9 +403,6 @@ func (scaleSet *ScaleSet) DeleteInstances(instances []*azureRef) error {
|
|||
return err
|
||||
}
|
||||
|
||||
scaleSet.instanceMutex.Lock()
|
||||
defer scaleSet.instanceMutex.Unlock()
|
||||
|
||||
instanceIDs := []string{}
|
||||
for _, instance := range instances {
|
||||
asg, err := scaleSet.manager.GetAsgForInstance(instance)
|
||||
|
|
@ -425,10 +414,12 @@ func (scaleSet *ScaleSet) DeleteInstances(instances []*azureRef) error {
|
|||
return fmt.Errorf("cannot delete instance (%s) which don't belong to the same Scale Set (%q)", instance.Name, commonAsg)
|
||||
}
|
||||
|
||||
scaleSet.instanceMutex.Lock()
|
||||
if cpi, found := scaleSet.getInstanceByProviderID(instance.Name); found && cpi.Status != nil && cpi.Status.State == cloudprovider.InstanceDeleting {
|
||||
klog.V(3).Infof("Skipping deleting instance %s as its current state is deleting", instance.Name)
|
||||
continue
|
||||
}
|
||||
scaleSet.instanceMutex.Unlock()
|
||||
|
||||
instanceID, err := getLastSegment(instance.Name)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in New Issue