mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 22:17:14 +00:00
add lock before detaching azure disk
fix build error
This commit is contained in:
parent
097d3f13d1
commit
f3324a6c26
@ -268,7 +268,7 @@ func (d *azureDiskDetacher) Detach(diskURI string, nodeName types.NodeName) erro
|
|||||||
return fmt.Errorf("invalid disk to detach: %q", diskURI)
|
return fmt.Errorf("invalid disk to detach: %q", diskURI)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := d.cloud.InstanceID(context.TODO(), nodeName)
|
instanceid, err := d.cloud.InstanceID(context.TODO(), nodeName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("no instance id for node %q, skip detaching (%v)", nodeName, err)
|
glog.Warningf("no instance id for node %q, skip detaching (%v)", nodeName, err)
|
||||||
return nil
|
return nil
|
||||||
@ -280,6 +280,10 @@ func (d *azureDiskDetacher) Detach(diskURI string, nodeName types.NodeName) erro
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getLunMutex.LockKey(instanceid)
|
||||||
|
defer getLunMutex.UnlockKey(instanceid)
|
||||||
|
|
||||||
err = diskController.DetachDiskByName("", diskURI, nodeName)
|
err = diskController.DetachDiskByName("", diskURI, nodeName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("failed to detach azure disk %q, err %v", diskURI, err)
|
glog.Errorf("failed to detach azure disk %q, err %v", diskURI, err)
|
||||||
|
Loading…
Reference in New Issue
Block a user