Skip to content

Commit a5a2a3a

Browse files
committed
Detect IPv6 clusters and apply correct policy
Dual stack load balancers in Kubernetes _must_ specify an IP family policy, or else it will be set to `SingleStack`. On AWS, IPv6 single stack is not supported, so update the test to reflect the new setting. Signed-off-by: Nolan Brubaker <nolan@nbrubaker.com> Assisted-By: Claude Sonnet 4.6 Signed-off-by: Nolan Brubaker <nolan@nbrubaker.com>
1 parent 54062fe commit a5a2a3a

1 file changed

Lines changed: 28 additions & 4 deletions

File tree

  • test/extended/cloud_controller_manager

test/extended/cloud_controller_manager/ccm.go

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,36 @@ var _ = g.Describe("[sig-cloud-provider][Feature:OpenShiftCloudControllerManager
9999
g.Skip("Skipped: There is no public subnet on AWS C2S/SC2S disconnected clusters!")
100100
}
101101

102+
infra, err := oc.AdminConfigClient().ConfigV1().Infrastructures().Get(context.Background(), "cluster", metav1.GetOptions{})
103+
o.Expect(err).NotTo(o.HaveOccurred())
104+
105+
isIPv6Primary := infra.Status.PlatformStatus.AWS != nil &&
106+
infra.Status.PlatformStatus.AWS.IPFamily == configv1.DualStackIPv6Primary
107+
102108
g.By("Create a cluster scope load balancer")
103109
svcName := "test-lb"
104-
defer oc.WithoutNamespace().AsAdmin().Run("delete").Args("-n", oc.Namespace(), "service", "loadbalancer", svcName, "--ignore-not-found").Execute()
105-
out, err := oc.AsAdmin().WithoutNamespace().Run("create").Args("-n", oc.Namespace(), "service", "loadbalancer", svcName, "--tcp=80:8080").Output()
106-
o.Expect(err).NotTo(o.HaveOccurred(), "failed to create lb service")
107-
o.Expect(out).To(o.ContainSubstring("service/" + svcName + " created"))
110+
defer oc.WithoutNamespace().AsAdmin().Run("delete").Args("service", fmt.Sprintf("%s/%s", oc.Namespace(), svcName), "--ignore-not-found").Execute()
111+
if isIPv6Primary {
112+
svcYAML := fmt.Sprintf(`apiVersion: v1
113+
kind: Service
114+
metadata:
115+
name: %s
116+
namespace: %s
117+
spec:
118+
type: LoadBalancer
119+
ipFamilyPolicy: PreferDualStack
120+
ports:
121+
- port: 80
122+
targetPort: 8080
123+
protocol: TCP
124+
`, svcName, oc.Namespace())
125+
err = oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", "-").InputString(svcYAML).Execute()
126+
o.Expect(err).NotTo(o.HaveOccurred(), "failed to create lb service")
127+
} else {
128+
out, err := oc.AsAdmin().WithoutNamespace().Run("create").Args("-n", oc.Namespace(), "service", "loadbalancer", svcName, "--tcp=80:8080").Output()
129+
o.Expect(err).NotTo(o.HaveOccurred(), "failed to create lb service")
130+
o.Expect(out).To(o.ContainSubstring("service/" + svcName + " created"))
131+
}
108132

109133
g.By("Check External-IP assigned")
110134
svcExternalIP := getLoadBalancerExternalIP(oc, oc.Namespace(), svcName)

0 commit comments

Comments
 (0)