-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OCPBUGS-31868: allow for some errors checking namespace delete #28761
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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{}) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think being in the loop here will just hammer it 6 times in a row without a pause in between and then exit. It is the PollUntilContextTimeout that waits in between the calls.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, I missed the sleep that you have but still not sure this is the best way. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, so if the error is nil we return false, nil If the error is not nil and not There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you wanting to quit polling after 6 consecutive failures? Maybe preserve the error and return it at the end.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, that was my intention originally. I've updated it now. look ok? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep I figured that was what you were going for, it just took me a couple of read throughs to get caught up... |
||||||
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()) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean to suppress the return false here? Looks like this just move the logging up but the comment in the jira had me thinking you wanted to keep polling. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suppose it would be return false, nil to keep polling but still log the error? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I confused myself that a but, if we There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had to go look it up earlier myself. I think by returning
|
||||||
return false, err | ||||||
lastError = err | ||||||
time.Sleep(5 * time.Second) | ||||||
} | ||||||
|
||||||
return false, nil | ||||||
return false, lastError | ||||||
} | ||||||
|
||||||
func (w *availability) Cleanup(ctx context.Context) error { | ||||||
|
@@ -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()) | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@neisw , how about something like this.
bumped the poller to 30s and then added 6 tries in the namespaceDeleted() in case it hits an error. So, if we did hit some error 6 times in a row then we log all of them and pass the last one back out to the poller which will exit and fail the test case.