diff --git a/pkg/cloudprovider/providers/vsphere/nodemanager.go b/pkg/cloudprovider/providers/vsphere/nodemanager.go index 493ea61045e35..c068a239afdab 100644 --- a/pkg/cloudprovider/providers/vsphere/nodemanager.go +++ b/pkg/cloudprovider/providers/vsphere/nodemanager.go @@ -18,13 +18,14 @@ package vsphere import ( "fmt" + "strings" + "sync" + "github.com/golang/glog" "golang.org/x/net/context" "k8s.io/api/core/v1" k8stypes "k8s.io/apimachinery/pkg/types" "k8s.io/kubernetes/pkg/cloudprovider/providers/vsphere/vclib" - "strings" - "sync" ) // Stores info about the kubernetes node @@ -241,6 +242,10 @@ func (nm *NodeManager) removeNode(node *v1.Node) { nm.registeredNodesLock.Lock() delete(nm.registeredNodes, node.ObjectMeta.Name) nm.registeredNodesLock.Unlock() + + nm.nodeInfoLock.Lock() + delete(nm.nodeInfoMap, node.ObjectMeta.Name) + nm.nodeInfoLock.Unlock() } // GetNodeInfo returns a NodeInfo which datacenter, vm and vc server ip address. diff --git a/pkg/cloudprovider/providers/vsphere/vsphere_util.go b/pkg/cloudprovider/providers/vsphere/vsphere_util.go index efedb06213993..62687d32ea0aa 100644 --- a/pkg/cloudprovider/providers/vsphere/vsphere_util.go +++ b/pkg/cloudprovider/providers/vsphere/vsphere_util.go @@ -32,12 +32,13 @@ import ( "fmt" + "path/filepath" + "github.com/vmware/govmomi/vim25/mo" "k8s.io/api/core/v1" k8stypes "k8s.io/apimachinery/pkg/types" "k8s.io/kubernetes/pkg/cloudprovider/providers/vsphere/vclib" "k8s.io/kubernetes/pkg/cloudprovider/providers/vsphere/vclib/diskmanagers" - "path/filepath" ) const ( @@ -194,13 +195,18 @@ func getSharedDatastoresInK8SCluster(ctx context.Context, dc *vclib.Datacenter, return nil, fmt.Errorf(msg) } var sharedDatastores []*vclib.DatastoreInfo - for index, nodeVmDetail := range nodeVmDetails { + for _, nodeVmDetail := range nodeVmDetails { glog.V(9).Infof("Getting accessible datastores for node %s", nodeVmDetail.NodeName) accessibleDatastores, err := getAccessibleDatastores(ctx, &nodeVmDetail, nodeManager) if err != nil { + if err == vclib.ErrNoVMFound { + glog.V(9).Infof("Got NoVMFound error for node %s", nodeVmDetail.NodeName) + continue + } return nil, err } - if index == 0 { + + if len(sharedDatastores) == 0 { sharedDatastores = accessibleDatastores } else { sharedDatastores = intersect(sharedDatastores, accessibleDatastores)