@@ -22,6 +22,7 @@ package managed
22
22
import (
23
23
"context"
24
24
"fmt"
25
+ "time"
25
26
26
27
"github.com/onsi/ginkgo"
27
28
. "github.com/onsi/gomega"
@@ -96,19 +97,32 @@ var _ = ginkgo.Describe("[managed] [general] [ipv6] EKS cluster tests", func() {
96
97
Name : clusterName ,
97
98
})
98
99
Expect (cluster ).NotTo (BeNil (), "couldn't find CAPI cluster" )
99
- // Don't replace this with var pods *corev1.PodsList as that results in a nil pointer error from List.
100
- pods := & corev1.PodList {}
101
- listOptions := []client.ListOption {
102
- client .InNamespace (namespace .Namespace ),
103
- client .MatchingLabels (map [string ]string {"app" : "aws-node" }),
104
- }
105
- clusterClient := e2eCtx .Environment .BootstrapClusterProxy .GetWorkloadCluster (ctx , namespace .Name , clusterName ).GetClient ()
106
- err := clusterClient .List (ctx , pods , listOptions ... )
107
- Expect (err ).ToNot (HaveOccurred ())
108
-
109
- for _ , pod := range pods .Items {
110
- Expect (net .IsIPv6String (pod .Status .PodIP )).To (BeTrue ())
111
- }
100
+
101
+ Eventually (func () bool {
102
+ pods := & corev1.PodList {}
103
+ listOptions := []client.ListOption {
104
+ client .InNamespace (namespace .Namespace ),
105
+ client .MatchingLabels (map [string ]string {"k8s-app" : "aws-node" }),
106
+ }
107
+ clusterClient := e2eCtx .Environment .BootstrapClusterProxy .GetWorkloadCluster (ctx , namespace .Name , clusterName ).GetClient ()
108
+ err := clusterClient .List (ctx , pods , listOptions ... )
109
+ Expect (err ).ToNot (HaveOccurred ())
110
+ shared .Byf ("checking if pods list is empty: %d" , len (pods .Items ))
111
+ if len (pods .Items ) == 0 {
112
+ return false
113
+ }
114
+ for _ , pod := range pods .Items {
115
+ shared .Byf ("checking if pod ip address is ipv6 based: %s/%s" , pod .Name , pod .Status .PodIP )
116
+ if pod .Status .PodIP == "" {
117
+ return false
118
+ }
119
+ if ! net .IsIPv6String (pod .Status .PodIP ) {
120
+ return false
121
+ }
122
+ }
123
+
124
+ return true
125
+ }).WithTimeout (5 * time .Minute ).WithPolling (10 * time .Second ).Should (BeTrue (), "failed to wait for pods to appear and have ipv6 address" )
112
126
113
127
framework .DeleteCluster (ctx , framework.DeleteClusterInput {
114
128
Deleter : e2eCtx .Environment .BootstrapClusterProxy .GetClient (),
0 commit comments