mirror of https://github.com/k3s-io/k3s
Ignore the available volume when calling DetachDisk
If use detachs the volume by nova in openstack env, volume becomes available. If nova instance is been deleted, nova will detach it automatically. So the "available" is fine since that means the volume is detached from instance already.pull/6/head
parent
9a277fba7d
commit
48db05166a
|
@ -215,11 +215,7 @@ func (os *OpenStack) AttachDisk(instanceID, volumeID string) (string, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
if volume.Status != VolumeAvailableStatus {
|
|
||||||
errmsg := fmt.Sprintf("volume %s status is %s, not %s, can not be attached to instance %s.", volume.Name, volume.Status, VolumeAvailableStatus, instanceID)
|
|
||||||
glog.Errorf(errmsg)
|
|
||||||
return "", errors.New(errmsg)
|
|
||||||
}
|
|
||||||
cClient, err := os.NewComputeV2()
|
cClient, err := os.NewComputeV2()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
@ -258,6 +254,12 @@ func (os *OpenStack) DetachDisk(instanceID, volumeID string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if volume.Status == VolumeAvailableStatus {
|
||||||
|
// "available" is fine since that means the volume is detached from instance already.
|
||||||
|
glog.V(2).Infof("volume: %s has been detached from compute: %s ", volume.ID, instanceID)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
if volume.Status != VolumeInUseStatus {
|
if volume.Status != VolumeInUseStatus {
|
||||||
errmsg := fmt.Sprintf("can not detach volume %s, its status is %s.", volume.Name, volume.Status)
|
errmsg := fmt.Sprintf("can not detach volume %s, its status is %s.", volume.Name, volume.Status)
|
||||||
glog.Errorf(errmsg)
|
glog.Errorf(errmsg)
|
||||||
|
|
Loading…
Reference in New Issue