Skip to content

Commit

Permalink
Pod creation is now retryable operation
Browse files Browse the repository at this point in the history
  • Loading branch information
nickytd committed May 21, 2024
1 parent 27b8df9 commit 3ee48e5
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions test/e2e/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,27 @@ var _ = Describe("Oidc Apps Deployment Framework Test", Ordered, func() {
pod *corev1.Pod
)

BeforeAll(func() {
// We need to implement a retryable operations in the BeforeAll block because the webhook server might not be
// initialized before the pod is created and the admission webhook is called. In the latter case, the pod creation
// will fail because the webhook server is not ready to serve the k8s-apiserver request.
BeforeAll(func(ctx SpecContext) {
// Create a deployment and the downstream replicaset and the pod as there is no controller to create them
time.Sleep(1 * time.Second)
deployment = createDeployment()
Expect(c.Create(context.TODO(), deployment)).Should(Succeed())
Eventually(
func() error { return c.Create(ctx, deployment) },
).WithPolling(100 * time.Millisecond).Should(Succeed())

replicaSet = createReplicaSet(deployment)
Expect(c.Create(context.TODO(), replicaSet)).Should(Succeed())
Eventually(
func() error { return c.Create(ctx, replicaSet) },
).WithPolling(100 * time.Millisecond).Should(Succeed())

pod = createPod(replicaSet)
Expect(c.Create(context.TODO(), pod)).Should(Succeed())
Eventually(
func() error { return c.Create(ctx, pod) },
).WithPolling(100 * time.Millisecond).Should(Succeed())

})
}, NodeTimeout(5*time.Second))

AfterAll(func() {
Expect(client.IgnoreNotFound(c.Delete(context.TODO(), deployment))).Should(Succeed())
Expand Down

0 comments on commit 3ee48e5

Please sign in to comment.