Skip to content

Commit

Permalink
Merge pull request #440 from andrewsykim/revert-dual-stack-1-18
Browse files Browse the repository at this point in the history
[v1.18] Revert dual stack nodes because GuestNicInfo does not guarentee network name
  • Loading branch information
k8s-ci-robot authored Mar 1, 2021
2 parents cf55170 + 8f83f45 commit 9ce6ca6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 80 deletions.
10 changes: 4 additions & 6 deletions pkg/cloudprovider/vsphere/nodemanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,6 @@ func (nm *NodeManager) DiscoverNode(nodeID string, searchBy cm.FindVM) error {
// Must break out of loop in the event of ipv6,ipv4 where the NIC does
// contain a valid IPv6 and IPV4 address
for _, family := range ipFamily {
foundInternal = false
foundExternal = false

ips := returnIPsFromSpecificFamily(family, v.IpAddress)

Expand Down Expand Up @@ -333,7 +331,7 @@ func (nm *NodeManager) DiscoverNode(nodeID string, searchBy cm.FindVM) error {
} else if !foundInternal && foundExternal {
klog.Warning("External address found, but internal address not found. Returning what addresses were discovered.")
}
continue
break
}

// Neither internal or external addresses were found. This defaults to the old
Expand All @@ -356,10 +354,10 @@ func (nm *NodeManager) DiscoverNode(nodeID string, searchBy cm.FindVM) error {
foundExternal = true
break
}
}

if !foundInternal && !foundExternal {
return fmt.Errorf("unable to find suitable IP address for node %s with IP family %s", nodeID, ipFamily)
}
if !foundInternal && !foundExternal {
return fmt.Errorf("unable to find suitable IP address for node %s with IP family %s", nodeID, ipFamily)
}
}

Expand Down
74 changes: 0 additions & 74 deletions pkg/cloudprovider/vsphere/nodemanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,80 +127,6 @@ func TestDiscoverNodeByName(t *testing.T) {
}
}

func TestAlphaDualStack(t *testing.T) {
cfg, ok := configFromEnvOrSim(true)
defer ok()

connMgr := cm.NewConnectionManager(cfg, nil, nil)
defer connMgr.Logout()

ipv4Ip := "10.0.0.1"
ipv6Ip := "fd01:0:101:2609:bdd2:ee20:7bd7:5836"

nm := newNodeManager(nil, connMgr)

vm := simulator.Map.Any("VirtualMachine").(*simulator.VirtualMachine)
vm.Guest.HostName = strings.ToLower(vm.Name) // simulator.SearchIndex.FindByDnsName matches against the guest.hostName property
vm.Guest.Net = []vimtypes.GuestNicInfo{
{
Network: "foo-bar",
IpAddress: []string{ipv4Ip, ipv6Ip},
},
}

err := connMgr.Connect(context.Background(), connMgr.VsphereInstanceMap[cfg.Global.VCenterIP])
if err != nil {
t.Errorf("Failed to Connect to vSphere: %s", err)
}

// set config for ip for vc to ipv4, ipv6 (dual-stack)
vcInstance := nm.connectionManager.VsphereInstanceMap[cfg.Global.VCenterIP]
vcInstance.Cfg.IPFamilyPriority = []string{"ipv6", "ipv4"}

name := vm.Name
UUID := vm.Config.Uuid
k8sUUID := ConvertK8sUUIDtoNormal(UUID)

node := &v1.Node{
ObjectMeta: metav1.ObjectMeta{
Name: name,
},
Status: v1.NodeStatus{
NodeInfo: v1.NodeSystemInfo{
SystemUUID: k8sUUID,
},
},
}

// get node registered so node can be exported
nm.RegisterNode(node)
err = nm.DiscoverNode(name, cm.FindVMByName)
if err != nil {
t.Errorf("Failed DiscoverNode: %s", err)
}

nodeList := make([]*pb.Node, 0)
_ = nm.ExportNodes("", "", &nodeList)

ips := nodeList[0].Addresses

ipv4Ips := returnIPsFromSpecificFamily(vcfg.IPv4Family, ips)
size := len(ipv4Ips)
if size != 1 {
t.Errorf("Should only return single IPv4 address. expected: 1, actual: %d", size)
} else if !strings.EqualFold(ipv4Ips[0], ipv4Ip) {
t.Errorf("IPv6 does not match. expected: %s, actual: %s", ipv4Ip, ipv4Ips[0])
}

ipv6Ips := returnIPsFromSpecificFamily(vcfg.IPv6Family, ips)
size = len(ipv6Ips)
if size != 1 {
t.Errorf("Should only return single IPv6 address. expected: 1, actual: %d", size)
} else if !strings.EqualFold(ipv6Ips[0], ipv6Ip) {
t.Errorf("IPv6 does not match. expected: fd01:0:101:2609:bdd2:ee20:7bd7:5836, actual: %s", ipv6Ips[0])
}
}

func TestExport(t *testing.T) {
cfg, ok := configFromEnvOrSim(true)
defer ok()
Expand Down

0 comments on commit 9ce6ca6

Please sign in to comment.