From ff7c781e25150eb0c0f7996a672badb2eba2ea6e Mon Sep 17 00:00:00 2001 From: Adrian Moisey Date: Sat, 5 Jul 2025 10:54:10 +0200 Subject: [PATCH] Loop over all IP address from each node Change the e2e test to test all InternalIPs from each node. https://github.com/kubernetes/kubernetes/blob/3d6e49e3c24324588c354ff38d5afdb1e27f204f/pkg/proxy/healthcheck/service_health.go#L66 --- test/e2e/network/loadbalancer.go | 49 +++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/test/e2e/network/loadbalancer.go b/test/e2e/network/loadbalancer.go index 9e8b9124c9d..5d9b632b225 100644 --- a/test/e2e/network/loadbalancer.go +++ b/test/e2e/network/loadbalancer.go @@ -1103,7 +1103,20 @@ var _ = common.SIGDescribe("LoadBalancers ExternalTrafficPolicy: Local", feature framework.Failf("Service HealthCheck NodePort was not allocated") } - ips := e2enode.CollectAddresses(nodes, v1.NodeInternalIP) + // Collect InternalIP addresses for each node. + nodeInternalIPs := make(map[string]sets.Set[string], len(nodes.Items)) + for i := range nodes.Items { + node := &nodes.Items[i] + internalIPs := sets.New[string]() + for _, addr := range node.Status.Addresses { + if addr.Type == v1.NodeInternalIP && addr.Address != "" { + internalIPs.Insert(addr.Address) + } + } + if internalIPs.Len() > 0 { + nodeInternalIPs[node.Name] = internalIPs + } + } ingressIP := e2eservice.GetIngressPoint(&svc.Status.LoadBalancer.Ingress[0]) svcTCPPort := int(svc.Spec.Ports[0].Port) @@ -1128,22 +1141,24 @@ var _ = common.SIGDescribe("LoadBalancers ExternalTrafficPolicy: Local", feature // HealthCheck should pass only on the node where num(endpoints) > 0 // All other nodes should fail the healthcheck on the service healthCheckNodePort - for n, internalIP := range ips { - // Make sure the loadbalancer picked up the health check change. - // Confirm traffic can reach backend through LB before checking healthcheck nodeport. - e2eservice.TestReachableHTTP(ctx, ingressIP, svcTCPPort, e2eservice.KubeProxyLagTimeout) - expectedSuccess := nodes.Items[n].Name == endpointNodeName - port := strconv.Itoa(healthCheckNodePort) - ipPort := net.JoinHostPort(internalIP, port) - framework.Logf("Health checking %s, http://%s/healthz, expectedSuccess %v", nodes.Items[n].Name, ipPort, expectedSuccess) - err := testHTTPHealthCheckNodePortFromTestContainer(ctx, - config, - internalIP, - healthCheckNodePort, - e2eservice.KubeProxyEndpointLagTimeout, - expectedSuccess, - threshold) - framework.ExpectNoError(err) + for n, internalIPs := range nodeInternalIPs { + for ip := range internalIPs { + // Make sure the loadbalancer picked up the health check change. + // Confirm traffic can reach backend through LB before checking healthcheck nodeport. + e2eservice.TestReachableHTTP(ctx, ingressIP, svcTCPPort, e2eservice.KubeProxyLagTimeout) + expectedSuccess := n == endpointNodeName + port := strconv.Itoa(healthCheckNodePort) + ipPort := net.JoinHostPort(ip, port) + framework.Logf("Health checking %s, http://%s/healthz, expectedSuccess %v", n, ipPort, expectedSuccess) + err := testHTTPHealthCheckNodePortFromTestContainer(ctx, + config, + ip, + healthCheckNodePort, + e2eservice.KubeProxyEndpointLagTimeout, + expectedSuccess, + threshold) + framework.ExpectNoError(err) + } } err = f.ClientSet.AppsV1().Deployments(namespace).Delete(ctx, serviceName, metav1.DeleteOptions{})