Merge pull request #103227 from hakman/fix_affinity-nodeport-timeout

nodeport tests: node addresses must match the service IP family
This commit is contained in:
Kubernetes Prow Robot 2021-06-26 01:45:23 -07:00 committed by GitHub
commit 303f2cef81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2497,9 +2497,13 @@ func execAffinityTestForSessionAffinityTimeout(f *framework.Framework, cs client
if serviceType == v1.ServiceTypeNodePort {
nodes, err := e2enode.GetReadySchedulableNodes(cs)
framework.ExpectNoError(err)
addrs := e2enode.CollectAddresses(nodes, v1.NodeInternalIP)
gomega.Expect(len(addrs)).To(gomega.BeNumerically(">", 0), "ginkgo.Failed to get Node internal IP")
svcIP = addrs[0]
// The node addresses must have the same IP family as the ClusterIP
family := v1.IPv4Protocol
if netutils.IsIPv6String(svc.Spec.ClusterIP) {
family = v1.IPv6Protocol
}
svcIP = e2enode.FirstAddressByTypeAndFamily(nodes, v1.NodeInternalIP, family)
framework.ExpectNotEqual(svcIP, "", "failed to get Node internal IP for family: %s", family)
servicePort = int(svc.Spec.Ports[0].NodePort)
} else {
svcIP = svc.Spec.ClusterIP
@ -2582,7 +2586,7 @@ func execAffinityTestForNonLBServiceWithOptionalTransition(f *framework.Framewor
family = v1.IPv6Protocol
}
svcIP = e2enode.FirstAddressByTypeAndFamily(nodes, v1.NodeInternalIP, family)
gomega.Expect(len(svcIP)).To(gomega.BeNumerically(">", 0), "ginkgo.Failed to get Node internal IP")
framework.ExpectNotEqual(svcIP, "", "failed to get Node internal IP for family: %s", family)
servicePort = int(svc.Spec.Ports[0].NodePort)
} else {
svcIP = svc.Spec.ClusterIP