Skip to content

Commit

Permalink
Merge pull request #28761 from jluhrsen/OCPBUGS-31868
Browse files Browse the repository at this point in the history
OCPBUGS-31868: allow for some errors checking namespace delete
  • Loading branch information
openshift-merge-bot[bot] authored May 4, 2024
2 parents 3a0e98a + 4979bad commit ab28660
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,17 +275,21 @@ func (w *availability) WriteContentToStorage(ctx context.Context, storageDir, ti
}

func (w *availability) namespaceDeleted(ctx context.Context) (bool, error) {
_, err := w.kubeClient.CoreV1().Namespaces().Get(ctx, w.namespaceName, metav1.GetOptions{})
if apierrors.IsNotFound(err) {
return true, nil
}
var lastError error
for retry := 0; retry < 6; retry++ {
_, err := w.kubeClient.CoreV1().Namespaces().Get(ctx, w.namespaceName, metav1.GetOptions{})
if apierrors.IsNotFound(err) {
return true, nil
}

if err != nil {
if err == nil {
return false, nil
}
logrus.Errorf("Error checking for deleted namespace: %s, %s", w.namespaceName, err.Error())
return false, err
lastError = err
time.Sleep(5 * time.Second)
}

return false, nil
return false, lastError
}

func (w *availability) Cleanup(ctx context.Context) error {
Expand All @@ -299,9 +303,9 @@ func (w *availability) Cleanup(ctx context.Context) error {

startTime := time.Now()
log.Info("waiting for namespace deletion to complete")
err := wait.PollUntilContextTimeout(ctx, 15*time.Second, 20*time.Minute, true, w.namespaceDeleted)
err := wait.PollUntilContextTimeout(ctx, 30*time.Second, 20*time.Minute, true, w.namespaceDeleted)
if err != nil {
log.WithError(err).Error("error waiting for namespace to delete")
log.Errorf("Encountered error while waiting for deleted namespace: %s, %s", w.namespaceName, err)
return err
}
log.Infof("namespace deleted in %.2f seconds", time.Now().Sub(startTime).Seconds())
Expand Down

0 comments on commit ab28660

Please sign in to comment.