mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #103180 from aojea/collect_ipfamily
Services tests for NodePorts must match the Node Address and Service IP family
This commit is contained in:
commit
017b359770
@ -105,11 +105,9 @@ var _ = common.SIGDescribe("Conntrack", func() {
|
||||
len(nodes.Items))
|
||||
}
|
||||
|
||||
var family v1.IPFamily
|
||||
family := v1.IPv4Protocol
|
||||
if framework.TestContext.ClusterIsIPv6() {
|
||||
family = v1.IPv6Protocol
|
||||
} else {
|
||||
family = v1.IPv4Protocol
|
||||
}
|
||||
|
||||
ips := e2enode.GetAddressesByTypeAndFamily(&nodes.Items[0], v1.NodeInternalIP, family)
|
||||
|
@ -29,26 +29,29 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
utilnet "k8s.io/apimachinery/pkg/util/net"
|
||||
utilrand "k8s.io/apimachinery/pkg/util/rand"
|
||||
|
||||
"k8s.io/client-go/tools/cache"
|
||||
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
discoveryv1 "k8s.io/api/discovery/v1"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
utilnet "k8s.io/apimachinery/pkg/util/net"
|
||||
utilrand "k8s.io/apimachinery/pkg/util/rand"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
watchtools "k8s.io/client-go/tools/watch"
|
||||
"k8s.io/client-go/util/retry"
|
||||
|
||||
cloudprovider "k8s.io/cloud-provider"
|
||||
netutils "k8s.io/utils/net"
|
||||
|
||||
"k8s.io/kubernetes/test/e2e/framework"
|
||||
e2edeployment "k8s.io/kubernetes/test/e2e/framework/deployment"
|
||||
e2eendpoints "k8s.io/kubernetes/test/e2e/framework/endpoints"
|
||||
@ -2573,9 +2576,13 @@ func execAffinityTestForNonLBServiceWithOptionalTransition(f *framework.Framewor
|
||||
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)
|
||||
gomega.Expect(len(svcIP)).To(gomega.BeNumerically(">", 0), "ginkgo.Failed to get Node internal IP")
|
||||
servicePort = int(svc.Spec.Ports[0].NodePort)
|
||||
} else {
|
||||
svcIP = svc.Spec.ClusterIP
|
||||
|
Loading…
Reference in New Issue
Block a user