mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-17 20:00:07 +00:00
Fallback to ExternalIP in tests.
Make test code behave like [GetNodeHostIPs()](https://pkg.go.dev/k8s.io/kubernetes/pkg/util/node#GetNodeHostIPs) First try InternalIP, then ExternalIP.
This commit is contained in:
@@ -78,6 +78,9 @@ var _ = common.SIGDescribe("HostPort", func() {
|
||||
randomNode := &nodes.Items[rand.Intn(len(nodes.Items))]
|
||||
|
||||
ips := e2enode.GetAddressesByTypeAndFamily(randomNode, v1.NodeInternalIP, family)
|
||||
if len(ips) == 0 {
|
||||
ips = e2enode.GetAddressesByTypeAndFamily(randomNode, v1.NodeExternalIP, family)
|
||||
}
|
||||
if len(ips) == 0 {
|
||||
framework.Failf("Failed to get NodeIP")
|
||||
}
|
||||
|
||||
@@ -4215,7 +4215,10 @@ func execAffinityTestForSessionAffinityTimeout(ctx context.Context, f *framework
|
||||
family = v1.IPv6Protocol
|
||||
}
|
||||
svcIP = e2enode.FirstAddressByTypeAndFamily(nodes, v1.NodeInternalIP, family)
|
||||
gomega.Expect(svcIP).NotTo(gomega.BeEmpty(), "failed to get Node internal IP for family: %s", family)
|
||||
if svcIP == "" {
|
||||
svcIP = e2enode.FirstAddressByTypeAndFamily(nodes, v1.NodeExternalIP, family)
|
||||
}
|
||||
gomega.Expect(svcIP).NotTo(gomega.BeEmpty(), "failed to get Node IP for family: %s", family)
|
||||
servicePort = int(svc.Spec.Ports[0].NodePort)
|
||||
} else {
|
||||
svcIP = svc.Spec.ClusterIP
|
||||
@@ -4298,7 +4301,10 @@ func execAffinityTestForNonLBServiceWithOptionalTransition(ctx context.Context,
|
||||
family = v1.IPv6Protocol
|
||||
}
|
||||
svcIP = e2enode.FirstAddressByTypeAndFamily(nodes, v1.NodeInternalIP, family)
|
||||
gomega.Expect(svcIP).NotTo(gomega.BeEmpty(), "failed to get Node internal IP for family: %s", family)
|
||||
if svcIP == "" {
|
||||
svcIP = e2enode.FirstAddressByTypeAndFamily(nodes, v1.NodeExternalIP, family)
|
||||
}
|
||||
gomega.Expect(svcIP).NotTo(gomega.BeEmpty(), "failed to get Node IP for family: %s", family)
|
||||
servicePort = int(svc.Spec.Ports[0].NodePort)
|
||||
} else {
|
||||
svcIP = svc.Spec.ClusterIP
|
||||
|
||||
@@ -1268,8 +1268,11 @@ func getNodeHostIP(ctx context.Context, f *framework.Framework, nodeName string)
|
||||
framework.ExpectNoError(err)
|
||||
ips := e2enode.GetAddressesByTypeAndFamily(node, v1.NodeInternalIP, family)
|
||||
if len(ips) == 0 {
|
||||
framework.Failf("No address by type (%s) and family (%s) on node (%s) found.",
|
||||
v1.NodeInternalIP, family, nodeName)
|
||||
ips = e2enode.GetAddressesByTypeAndFamily(node, v1.NodeExternalIP, family)
|
||||
}
|
||||
if len(ips) == 0 {
|
||||
framework.Failf("No address by family (%s) on node (%s) found.",
|
||||
family, nodeName)
|
||||
}
|
||||
return ips[0]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user