Skip to content

Commit

Permalink
add retry loop for conflicts on pod creation (#3215)
Browse files Browse the repository at this point in the history
  • Loading branch information
vaikas authored May 28, 2020
1 parent c55c44c commit c607c29
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions test/lib/creation.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
"knative.dev/eventing/test/lib/duck"
"knative.dev/eventing/test/lib/resources"
duckv1 "knative.dev/pkg/apis/duck/v1"
"knative.dev/pkg/reconciler"
)

// TODO(chizhg): break this file into multiple files when it grows too large.
Expand Down Expand Up @@ -373,8 +374,12 @@ func (c *Client) CreatePodOrFail(pod *corev1.Pod, options ...func(*corev1.Pod, *
c.T.Fatalf("Failed to configure pod %q: %v", pod.Name, err)
}
}
c.T.Logf("Creating pod %+v", pod)
if _, err := c.Kube.CreatePod(pod); err != nil {
err := reconciler.RetryUpdateConflicts(func(attempts int) (err error) {
c.T.Logf("Creating pod %+v", pod)
_, e := c.Kube.CreatePod(pod)
return e
})
if err != nil {
c.T.Fatalf("Failed to create pod %q: %v", pod.Name, err)
}
c.Tracker.Add(coreAPIGroup, coreAPIVersion, "pods", namespace, pod.Name)
Expand Down

0 comments on commit c607c29

Please sign in to comment.