mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #56726 from vmware/issue_390
Automatic merge from submit-queue (batch tested with PRs 56639, 56746, 56715, 56673, 56726). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Fix issue #390 **What this PR does / why we need it**: When VM node is removed from vSphere Inventory, the corresponding Kubernetes node is unregistered and removed from registeredNodes cache in nodemanager. However, it is not removed from the other node info cache in nodemanager. The fix is to update the other cache accordingly. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes https://github.com/vmware/kubernetes/issues/390 **Special notes for your reviewer**: Internally review PR here: https://github.com/vmware/kubernetes/pull/402 **Release note**: ``` NONE ``` Testing Done: 1. Removed the node VM from vSphere inventory. 2. Create storageclass and pvc to provision volume dynamically
This commit is contained in:
commit
8475a9217a
@ -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.
|
||||
|
@ -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 (
|
||||
@ -199,13 +200,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)
|
||||
|
Loading…
Reference in New Issue
Block a user