Change:
Command run: vSphere intree volume test suite occasionally failed with the following error: The test suite should always pass. We may have a chance to hit this by running ` No response binary version: 1.27.4 </details<detailsvsphere </details<details</details<details</details<details</details<details</details
/assign
/sig testing storage ?
/triage accepted

Discussion:
if err != nil { framework.Failf("Failed to get nodes: %v", err) } <del> TestContext = Context{NodeMapper: &NodeMapper{}, VSphereInstances: vsphereInstances} </del> <ins> TestContext = Context{NodeMapper: NewNodeMapper(), VSphereInstances: vsphereInstances} </ins> // 3. Get Node to VSphere mapping err = TestContext.NodeMapper.GenerateNodeMap(vsphereInstances, *nodeList) if err != nil {

// NodeMapper contains information to generate nameToNodeInfo and vcToZoneDatastore maps type NodeMapper struct { <ins> nodeInfoRWLock        *sync.RWMutex nameToNodeInfo        map[string]*NodeInfo vcToZoneDatastoresMap map[string](map[string][]string) </ins> } // NodeInfo contains information about vcenter nodes

hostSystemType             = "HostSystem" ) <del> var ( nameToNodeInfo        = make(map[string]*NodeInfo) vcToZoneDatastoresMap = make(map[string](map[string][]string)) ) </del> <ins> // NewNodeMapper returns a new NodeMapper func NewNodeMapper() *NodeMapper { return &NodeMapper{ nodeInfoRWLock:        &sync.RWMutex{}, nameToNodeInfo:        make(map[string]*NodeInfo), vcToZoneDatastoresMap: make(map[string](map[string][]string)), } } </ins> // GenerateNodeMap populates node name to node info map func (nm *NodeMapper) GenerateNodeMap(vSphereInstances map[string]*VSphere, nodeList v1.NodeList) error {

for _, node := range nodeList.Items { n := node <ins> wg.Add(1) </ins> go func() { nodeUUID := getUUIDFromProviderID(n.Spec.ProviderID) framework.Logf("Searching for node with UUID: %s", nodeUUID)

} wg.Done() }() <del> wg.Add(1) </del> } wg.Wait() <del> if len(nameToNodeInfo) != len(nodeList.Items) { </del> <ins> if len(nm.nameToNodeInfo) != len(nodeList.Items) { </ins> return errors.New("all nodes not mapped to respective vSphere") } return nil

ctx, cancel := context.WithCancel(context.Background()) defer cancel() // 3. Populate vcToZoneHostsMap and vcToHostDatastoresMap <del> for _, nodeInfo := range nameToNodeInfo { </del> <ins> for _, nodeInfo := range nm.nameToNodeInfo { </ins> vc := nodeInfo.VSphere.Config.Hostname host := nodeInfo.HostSystemRef.Value for _, zone := range nodeInfo.Zones {

for vc, zoneToHostsMap := range vcToZoneHostsMap { for zone, hosts := range zoneToHostsMap { commonDatastores := retrieveCommonDatastoresAmongHosts(hosts, vcToHostDatastoresMap[vc]) <del> if vcToZoneDatastoresMap[vc] == nil { vcToZoneDatastoresMap[vc] = make(map[string][]string) </del> <ins> if nm.vcToZoneDatastoresMap[vc] == nil { nm.vcToZoneDatastoresMap[vc] = make(map[string][]string) </ins> } <del> vcToZoneDatastoresMap[vc][zone] = commonDatastores </del> <ins> nm.vcToZoneDatastoresMap[vc][zone] = commonDatastores </ins> } } <del> framework.Logf("Zone to datastores map : %+v", vcToZoneDatastoresMap) </del> <ins> framework.Logf("Zone to datastores map : %+v", nm.vcToZoneDatastoresMap) </ins> return nil }

// GetDatastoresInZone returns all the datastores in the specified zone func (nm *NodeMapper) GetDatastoresInZone(vc string, zone string) []string { <del> return vcToZoneDatastoresMap[vc][zone] </del> <ins> nm.nodeInfoRWLock.RLock() defer nm.nodeInfoRWLock.RUnlock() return nm.vcToZoneDatastoresMap[vc][zone] </ins> } // GetNodeInfo returns NodeInfo for given nodeName func (nm *NodeMapper) GetNodeInfo(nodeName string) *NodeInfo { <del> return nameToNodeInfo[nodeName] </del> <ins> nm.nodeInfoRWLock.RLock() defer nm.nodeInfoRWLock.RUnlock() return nm.nameToNodeInfo[nodeName] </ins> } // SetNodeInfo sets NodeInfo for given nodeName. This function is not thread safe. Users need to handle concurrency. func (nm *NodeMapper) SetNodeInfo(nodeName string, nodeInfo *NodeInfo) { <del> nameToNodeInfo[nodeName] = nodeInfo </del> <ins> nm.nodeInfoRWLock.Lock() defer nm.nodeInfoRWLock.Unlock() nm.nameToNodeInfo[nodeName] = nodeInfo </ins> }