Skip to content

Commit

Permalink
install: Wait for test pods to be cleaned up
Browse files Browse the repository at this point in the history
[ upstream commit b3d0e95 ]

 If test pods deletion takes longer than that of (cni)
 cilium pods, test pods are stuck in the "terminating"
 state. This ends up failing CI jobs in the clean-up stage.
 Hence, wait until test pods are deleted before moving
 onto the CNI related clean-up.

Signed-off-by: Aditi Ghag <[email protected]>
Signed-off-by: Gilberto Bertin <[email protected]>
  • Loading branch information
aditighag authored and tklauser committed May 31, 2022
1 parent d7e5a83 commit 04b4759
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions install/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@ func (k *K8sUninstaller) Uninstall(ctx context.Context) error {
k.Log("🔥 Deleting %s namespace...", k.params.TestNamespace)
k.client.DeleteNamespace(ctx, k.params.TestNamespace, metav1.DeleteOptions{})

// To avoid cases where test pods are stuck in terminating state because
// cni (cilium) pods were deleted sooner, wait until test pods are deleted
// before moving onto deleting cilium pods.
if k.params.Wait {
retryNamespace:
// Wait for the test namespace to be terminated. Subsequent connectivity checks would fail
// if the test namespace is in Terminating state.
_, err := k.client.GetNamespace(ctx, k.params.TestNamespace, metav1.GetOptions{})
if err == nil {
time.Sleep(defaults.WaitRetryInterval)
k.Log("⌛ Waiting for %s namespace to be terminated...", k.params.TestNamespace)
goto retryNamespace
}
}

k.Log("🔥 Deleting Service accounts...")
k.client.DeleteServiceAccount(ctx, k.params.Namespace, defaults.AgentServiceAccountName, metav1.DeleteOptions{})
k.client.DeleteServiceAccount(ctx, k.params.Namespace, defaults.OperatorServiceAccountName, metav1.DeleteOptions{})
Expand Down Expand Up @@ -104,16 +119,6 @@ func (k *K8sUninstaller) Uninstall(ctx context.Context) error {
time.Sleep(defaults.WaitRetryInterval)
goto retry
}

k.Log("⌛ Waiting for %s namespace to be terminated...", k.params.TestNamespace)
retryNamespace:
// Wait for the test namespace to be terminated. Subsequent connectivity checks would fail
// if the test namespace is in Terminating state.
_, err = k.client.GetNamespace(ctx, k.params.TestNamespace, metav1.GetOptions{})
if err == nil {
time.Sleep(defaults.WaitRetryInterval)
goto retryNamespace
}
}

k.Log("✅ Cilium was successfully uninstalled.")
Expand Down

0 comments on commit 04b4759

Please sign in to comment.