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

Commit 74a0b93

Browse files
author
Kubernetes Submit Queue
authored
Merge pull request #50239 from FengyunPan/fix-no-exist-node
Automatic merge from submit-queue (batch tested with PRs 38947, 50239, 51115, 51094, 51116) Mark the volumes as detached when node does not exist If node does not exist, node's volumes will be detached automatically and become available. So mark them detached and do not return err. **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes # #50200 **Release note**: ```release-note NONE ```
2 parents c6c81bf + c1f1f2d commit 74a0b93

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
@@ -126,6 +126,9 @@ func (os *OpenStack) InstanceID() (string, error) {
126126
func (i *Instances) InstanceID(name types.NodeName) (string, error) {
127127
srv, err := getServerByName(i.compute, name)
128128
if err != nil {
129+
if err == ErrNotFound {
130+
return "", cloudprovider.InstanceNotFound
131+
}
129132
return "", err
130133
}
131134
// 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)