e2e: Add retry logic in calico test
If pod creation fails for some reason in first attempt then try again.
@@ -52,6 +52,7 @@ spec:
- --timeout
- "5"
`
+
retryInterval = 1 * time.Second
timeout = 5 * time.Minute
)
@@ -97,9 +98,18 @@ func TestNoMetadataAccessRandomPod(t *testing.T) { //nolint:funlen
podsclient := client.Pods(ns.ObjectMeta.Name)
+ // Retry pod creation. This might fail if Linkerd is not ready yet and some requests might fail.
+ if err := wait.PollImmediate(retryInterval, timeout, func() (done bool, err error) {
p, err = podsclient.Create(context.TODO(), p, metav1.CreateOptions{})
if err != nil {
- t.Fatalf("failed creating Pod: %v", err)
+ t.Logf("retrying pod creation, failed with: %v", err)
+
+ return false, nil
+ }
+
+ return true, nil
+ }); err != nil {
+ t.Fatalf("error while trying to create the pod: %v", err)
}
phase := corev1.PodUnknown
