From 1a323279a287fdd73c6f3424c4ea3ca3b999ed1f Mon Sep 17 00:00:00 2001 From: Hemant Kumar Date: Thu, 19 Nov 2020 06:30:44 -0500 Subject: [PATCH] Address review comments --- .../src/k8s.io/legacy-cloud-providers/vsphere/nodemanager.go | 2 ++ staging/src/k8s.io/legacy-cloud-providers/vsphere/vsphere.go | 2 +- .../src/k8s.io/legacy-cloud-providers/vsphere/vsphere_util.go | 2 +- .../legacy-cloud-providers/vsphere/vsphere_volume_map.go | 3 +++ 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/staging/src/k8s.io/legacy-cloud-providers/vsphere/nodemanager.go b/staging/src/k8s.io/legacy-cloud-providers/vsphere/nodemanager.go index 29d4abe517d..04c49a1aba3 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/vsphere/nodemanager.go +++ b/staging/src/k8s.io/legacy-cloud-providers/vsphere/nodemanager.go @@ -311,6 +311,8 @@ func (nm *NodeManager) GetNodeDetails() ([]NodeDetails, error) { return nodeDetails, nil } +// GetNodeNames returns list of nodes that are known to vsphere cloudprovider. +// These are typically nodes that make up k8s cluster. func (nm *NodeManager) GetNodeNames() []k8stypes.NodeName { nodes := nm.getNodes() var nodeNameList []k8stypes.NodeName diff --git a/staging/src/k8s.io/legacy-cloud-providers/vsphere/vsphere.go b/staging/src/k8s.io/legacy-cloud-providers/vsphere/vsphere.go index ddf3a694b1e..83337adc7c2 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/vsphere/vsphere.go +++ b/staging/src/k8s.io/legacy-cloud-providers/vsphere/vsphere.go @@ -1221,7 +1221,7 @@ func (vs *VSphere) DisksAreAttached(nodeVolumes map[k8stypes.NodeName][]string) } } - klog.V(4).Infof("DisksAreAttach successfully executed. result: %+v", attached) + klog.V(4).Infof("DisksAreAttached successfully executed. result: %+v", attached) // There could be nodes in cluster which do not have any pods with vsphere volumes running on them // such nodes won't be part of nodeVolumes map because attach-detach controller does not keep track // such nodes. But such nodes may still have dangling volumes on them and hence we need to scan all the diff --git a/staging/src/k8s.io/legacy-cloud-providers/vsphere/vsphere_util.go b/staging/src/k8s.io/legacy-cloud-providers/vsphere/vsphere_util.go index 7262ca573ad..c0d474ab557 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/vsphere/vsphere_util.go +++ b/staging/src/k8s.io/legacy-cloud-providers/vsphere/vsphere_util.go @@ -636,6 +636,7 @@ func (vs *VSphere) BuildMissingVolumeNodeMap(ctx context.Context) { for _, nodeNames := range dcNodes { // Start go routines per VC-DC to check disks are attached + wg.Add(1) go func(nodes []k8stypes.NodeName) { err := vs.checkNodeDisks(ctx, nodeNames) if err != nil { @@ -643,7 +644,6 @@ func (vs *VSphere) BuildMissingVolumeNodeMap(ctx context.Context) { } wg.Done() }(nodeNames) - wg.Add(1) } wg.Wait() } diff --git a/staging/src/k8s.io/legacy-cloud-providers/vsphere/vsphere_volume_map.go b/staging/src/k8s.io/legacy-cloud-providers/vsphere/vsphere_volume_map.go index d5307019081..6895bf90280 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/vsphere/vsphere_volume_map.go +++ b/staging/src/k8s.io/legacy-cloud-providers/vsphere/vsphere_volume_map.go @@ -74,6 +74,9 @@ func (vsphereVolume *VsphereVolumeMap) CheckForVolume(path string) (k8stypes.Nod return "", false } +// CheckForNode returns true if given node has already been processed by volume +// verification mechanism. This is used to skip verifying attached disks on nodes +// which were previously verified. func (vsphereVolume *VsphereVolumeMap) CheckForNode(nodeName k8stypes.NodeName) bool { vsphereVolume.lock.RLock() defer vsphereVolume.lock.RUnlock()