From ebac6dddb4fe9e70a71c5604e55821b138a3c9cc Mon Sep 17 00:00:00 2001 From: FengyunPan Date: Tue, 8 Aug 2017 10:28:58 +0800 Subject: [PATCH] Mark volume as detached when node does not exist for photon If node does not exist, node's volumes will be detached automatically and become available. So mark them detached and return false without error. Fix #50266 --- pkg/cloudprovider/providers/photon/photon.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/cloudprovider/providers/photon/photon.go b/pkg/cloudprovider/providers/photon/photon.go index 8ef0b1dcfcc..7bbf50cff3e 100644 --- a/pkg/cloudprovider/providers/photon/photon.go +++ b/pkg/cloudprovider/providers/photon/photon.go @@ -620,6 +620,10 @@ func (pc *PCCloud) DiskIsAttached(pdID string, nodeName k8stypes.NodeName) (bool } vmID, err := pc.InstanceID(nodeName) + if err == cloudprovider.InstanceNotFound { + glog.Infof("Instance %q does not exist, disk %s will be detached automatically.", nodeName, pdID) + return false, nil + } if err != nil { glog.Errorf("Photon Cloud Provider: pc.InstanceID failed for DiskIsAttached. Error[%v]", err) return false, err @@ -648,6 +652,11 @@ func (pc *PCCloud) DisksAreAttached(pdIDs []string, nodeName k8stypes.NodeName) } vmID, err := pc.InstanceID(nodeName) + if err == cloudprovider.InstanceNotFound { + glog.Infof("Instance %q does not exist, its disks will be detached automatically.", nodeName) + // make all the disks as detached. + return attached, nil + } if err != nil { glog.Errorf("Photon Cloud Provider: pc.InstanceID failed for DiskIsAttached. Error[%v]", err) return attached, err