@@ -27,6 +27,7 @@ import (
2727 "k8s.io/kubernetes/test/utils/image"
2828 "k8s.io/pod-security-admission/api"
2929 "k8s.io/utils/exec"
30+ utilnet "k8s.io/utils/net"
3031 "k8s.io/utils/ptr"
3132
3233 operatorv1 "github.com/openshift/api/operator/v1"
@@ -123,12 +124,18 @@ var _ = g.Describe("[sig-network-edge][Feature:Router][apigroup:route.openshift.
123124 o .Expect (err ).NotTo (o .HaveOccurred ())
124125 o .Expect (pods .Items ).To (o .HaveLen (1 ))
125126
127+ // Use the appropriate loopback address based on the pod's IP family.
128+ // IPv6-only clusters won't have 127.0.0.1 available.
129+ loopback := "127.0.0.1"
130+ if utilnet .IsIPv6String (pods .Items [0 ].Status .PodIP ) {
131+ loopback = "::1"
132+ }
126133 execPod = execPodRef {
127134 NamespacedName : types.NamespacedName {
128135 Namespace : pods .Items [0 ].Namespace ,
129136 Name : pods .Items [0 ].Name ,
130137 },
131- ipAddress : "127.0.0.1" ,
138+ ipAddress : loopback ,
132139 }
133140 })
134141
@@ -521,7 +528,7 @@ var _ = g.Describe("[sig-network-edge][Feature:Router][apigroup:route.openshift.
521528 getMetric := func (metricName string ) int {
522529 cmd := fmt .Sprintf (
523530 `curl -sS %s:1936/metrics --user %s:%s | grep '^%s.*route="%s"' | sed 's/.* //'` ,
524- execPod .ipAddress , statsUser , statsPasswd , metricName , resourceName )
531+ exutil . IPUrl ( execPod .ipAddress ) , statsUser , statsPasswd , metricName , resourceName )
525532 output , err := e2eoutput .RunHostCmd (execPod .Namespace , execPod .Name , cmd )
526533 o .Expect (err ).NotTo (o .HaveOccurred ())
527534 if output == "" {
0 commit comments