Skip to content

Commit 41a6359

Browse files
authored
[cinder-csi-plugin]: do not allow DetachVolume when status is detaching (#2965)
1 parent c93d263 commit 41a6359

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
@@ -43,6 +43,7 @@ import (
4343
const (
4444
VolumeAvailableStatus = "available"
4545
VolumeInUseStatus = "in-use"
46+
VolumeDetachingStatus = "detaching"
4647
operationFinishInitDelay = 1 * time.Second
4748
operationFinishFactor = 1.1
4849
operationFinishSteps = 10
@@ -307,6 +308,11 @@ func (os *OpenStack) DetachVolume(ctx context.Context, instanceID, volumeID stri
307308
klog.V(2).Infof("volume: %s has been detached from compute: %s ", volume.ID, instanceID)
308309
return nil
309310
}
311+
// If the volume is already in detaching state, we can return nil
312+
if volume.Status == VolumeDetachingStatus {
313+
klog.V(2).Infof("volume: %s is already in detaching state from compute %s ", volume.ID, instanceID)
314+
return nil
315+
}
310316

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

0 commit comments

Comments
 (0)