Commit 63725e3e authored by FengyunPan's avatar FengyunPan

Mark the volumes as detached when node does not exist

If node doesn't exist, OpenStack Nova will assume the volumes are not attached to it. So mark the volumes as detached and return false without error. Fix: #50200
parent e0c3eafa
...@@ -157,6 +157,9 @@ func (os *OpenStack) InstanceID() (string, error) { ...@@ -157,6 +157,9 @@ func (os *OpenStack) InstanceID() (string, error) {
func (i *Instances) InstanceID(name types.NodeName) (string, error) { func (i *Instances) InstanceID(name types.NodeName) (string, error) {
srv, err := getServerByName(i.compute, name) srv, err := getServerByName(i.compute, name)
if err != nil { if err != nil {
if err == ErrNotFound {
return "", cloudprovider.InstanceNotFound
}
return "", err return "", err
} }
// In the future it is possible to also return an endpoint as: // In the future it is possible to also return an endpoint as:
......
...@@ -26,6 +26,7 @@ import ( ...@@ -26,6 +26,7 @@ import (
"github.com/golang/glog" "github.com/golang/glog"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
"k8s.io/kubernetes/pkg/cloudprovider"
"k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume"
volumeutil "k8s.io/kubernetes/pkg/volume/util" volumeutil "k8s.io/kubernetes/pkg/volume/util"
...@@ -186,6 +187,17 @@ func (attacher *cinderDiskAttacher) VolumesAreAttached(specs []*volume.Spec, nod ...@@ -186,6 +187,17 @@ func (attacher *cinderDiskAttacher) VolumesAreAttached(specs []*volume.Spec, nod
instanceID, err := attacher.nodeInstanceID(nodeName) instanceID, err := attacher.nodeInstanceID(nodeName)
if err != nil { if err != nil {
if err == cloudprovider.InstanceNotFound {
// If node doesn't exist, OpenStack Nova will assume the volumes are not attached to it.
// Mark the volumes as detached and return false without error.
glog.Warningf("VolumesAreAttached: node %q does not exist.", nodeName)
for spec := range volumesAttachedCheck {
volumesAttachedCheck[spec] = false
}
return volumesAttachedCheck, nil
}
return volumesAttachedCheck, err return volumesAttachedCheck, err
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment