Skip to content

Commit cf84030

Browse files
do not allow DetachVolume when status is detaching (#2974)
Co-authored-by: Ansou FALL <[email protected]>
1 parent c33d1c7 commit cf84030

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pkg/csi/cinder/openstack/openstack_volumes.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import (
4040
const (
4141
VolumeAvailableStatus = "available"
4242
VolumeInUseStatus = "in-use"
43+
VolumeDetachingStatus = "detaching"
4344
operationFinishInitDelay = 1 * time.Second
4445
operationFinishFactor = 1.1
4546
operationFinishSteps = 10
@@ -301,6 +302,11 @@ func (os *OpenStack) DetachVolume(ctx context.Context, instanceID, volumeID stri
301302
klog.V(2).Infof("volume: %s has been detached from compute: %s ", volume.ID, instanceID)
302303
return nil
303304
}
305+
// If the volume is already in detaching state, we can return nil
306+
if volume.Status == VolumeDetachingStatus {
307+
klog.V(2).Infof("volume: %s is already in detaching state from compute %s ", volume.ID, instanceID)
308+
return nil
309+
}
304310

305311
if volume.Status != VolumeInUseStatus {
306312
return fmt.Errorf("can not detach volume %s, its status is %s", volume.Name, volume.Status)

0 commit comments

Comments
 (0)