Skip to content
This repository was archived by the owner on Mar 22, 2018. It is now read-only.

Commit 7f023c2

Browse files
author
Kubernetes Submit Queue
authored
Merge pull request #50208 from FengyunPan/fix-volume-detach
Automatic merge from submit-queue Ignore the available volume when calling DetachDisk Fix #50207 If user detachs the volume by nova in openstack env, volume becomes available. If nova instance is been deleted, nova will detach it automatically and become available. So the "available" is fine since that means the volume is detached from instance already. **Release note**: ```release-note NONE ```
2 parents c819e2b + 5d09d31 commit 7f023c2

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

pkg/cloudprovider/providers/openstack/openstack_volumes.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,7 @@ func (os *OpenStack) AttachDisk(instanceID, volumeID string) (string, error) {
215215
if err != nil {
216216
return "", err
217217
}
218-
if volume.Status != VolumeAvailableStatus {
219-
errmsg := fmt.Sprintf("volume %s status is %s, not %s, can not be attached to instance %s.", volume.Name, volume.Status, VolumeAvailableStatus, instanceID)
220-
glog.Errorf(errmsg)
221-
return "", errors.New(errmsg)
222-
}
218+
223219
cClient, err := os.NewComputeV2()
224220
if err != nil {
225221
return "", err
@@ -256,6 +252,12 @@ func (os *OpenStack) DetachDisk(instanceID, volumeID string) error {
256252
if err != nil {
257253
return err
258254
}
255+
if volume.Status == VolumeAvailableStatus {
256+
// "available" is fine since that means the volume is detached from instance already.
257+
glog.V(2).Infof("volume: %s has been detached from compute: %s ", volume.ID, instanceID)
258+
return nil
259+
}
260+
259261
if volume.Status != VolumeInUseStatus {
260262
errmsg := fmt.Sprintf("can not detach volume %s, its status is %s.", volume.Name, volume.Status)
261263
glog.Errorf(errmsg)

0 commit comments

Comments
 (0)