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

Commit c1f1f2d

Browse files
author
FengyunPan
committed
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
1 parent f031be0 commit c1f1f2d

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

pkg/cloudprovider/providers/openstack/openstack_instances.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ func (os *OpenStack) InstanceID() (string, error) {
157157
func (i *Instances) InstanceID(name types.NodeName) (string, error) {
158158
srv, err := getServerByName(i.compute, name)
159159
if err != nil {
160+
if err == ErrNotFound {
161+
return "", cloudprovider.InstanceNotFound
162+
}
160163
return "", err
161164
}
162165
// In the future it is possible to also return an endpoint as:

pkg/volume/cinder/attacher.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/golang/glog"
2727
"k8s.io/apimachinery/pkg/types"
2828
"k8s.io/apimachinery/pkg/util/wait"
29+
"k8s.io/kubernetes/pkg/cloudprovider"
2930
"k8s.io/kubernetes/pkg/util/mount"
3031
"k8s.io/kubernetes/pkg/volume"
3132
volumeutil "k8s.io/kubernetes/pkg/volume/util"
@@ -186,6 +187,17 @@ func (attacher *cinderDiskAttacher) VolumesAreAttached(specs []*volume.Spec, nod
186187

187188
instanceID, err := attacher.nodeInstanceID(nodeName)
188189
if err != nil {
190+
if err == cloudprovider.InstanceNotFound {
191+
// If node doesn't exist, OpenStack Nova will assume the volumes are not attached to it.
192+
// Mark the volumes as detached and return false without error.
193+
glog.Warningf("VolumesAreAttached: node %q does not exist.", nodeName)
194+
for spec := range volumesAttachedCheck {
195+
volumesAttachedCheck[spec] = false
196+
}
197+
198+
return volumesAttachedCheck, nil
199+
}
200+
189201
return volumesAttachedCheck, err
190202
}
191203

0 commit comments

Comments
 (0)