Skip to content

Commit

Permalink
Hopefully fix E2E flake related to deletion of a test Service (#3336)
Browse files Browse the repository at this point in the history
* Wrap Delete call in Eventually to hopefully prevent flakes where Service deletion fails

* Simplify logic and properly handle the case where the Service is not
found during the delete call

* After deleting the Service, confirm that it's gone
  • Loading branch information
kimorris27 authored Jan 31, 2024
1 parent 2a0ef0e commit 087e409
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions test/e2e/adminapi_delete_managedresource.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,16 @@ var _ = Describe("[Admin API] Delete managed resource action", func() {

defer func() {
By("cleaning up the k8s loadbalancer service")
err := clients.Kubernetes.CoreV1().Services("default").Delete(ctx, "test", metav1.DeleteOptions{})
Expect(err).NotTo(HaveOccurred())

// wait for deletion to prevent flakes on retries
Eventually(func(g Gomega, ctx context.Context) {
_, err = clients.Kubernetes.CoreV1().Services("default").Get(ctx, "test", metav1.GetOptions{})
g.Expect(kerrors.IsNotFound(err)).To(BeTrue(), "expect Service to be deleted")
err := clients.Kubernetes.CoreV1().Services("default").Delete(ctx, "test", metav1.DeleteOptions{})
g.Expect((err == nil || kerrors.IsNotFound(err))).To(BeTrue(), "expect Service to be deleted")
}).WithContext(ctx).WithTimeout(DefaultEventuallyTimeout).Should(Succeed())

By("confirming that the k8s loadbalancer service is gone")
Eventually(func(g Gomega, ctx context.Context) {
_, err := clients.Kubernetes.CoreV1().Services("default").Get(ctx, "test", metav1.GetOptions{})
g.Expect(kerrors.IsNotFound(err)).To(BeTrue())
}).WithContext(ctx).WithTimeout(DefaultEventuallyTimeout).Should(Succeed())
}()

Expand Down

0 comments on commit 087e409

Please sign in to comment.