Skip to content

Commit 7ae2326

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

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
@@ -36,6 +36,7 @@ import (
3636
const (
3737
VolumeAvailableStatus = "available"
3838
VolumeInUseStatus = "in-use"
39+
VolumeDetachingStatus = "detaching"
3940
operationFinishInitDelay = 1 * time.Second
4041
operationFinishFactor = 1.1
4142
operationFinishSteps = 10
@@ -292,6 +293,11 @@ func (os *OpenStack) DetachVolume(instanceID, volumeID string) error {
292293
klog.V(2).Infof("volume: %s has been detached from compute: %s ", volume.ID, instanceID)
293294
return nil
294295
}
296+
// If the volume is already in detaching state, we can return nil
297+
if volume.Status == VolumeDetachingStatus {
298+
klog.V(2).Infof("volume: %s is already in detaching state from compute %s ", volume.ID, instanceID)
299+
return nil
300+
}
295301

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

0 commit comments

Comments
 (0)