fix(kube): always propagate context.Canceled in WaitForDelete

The previous change suppressed ctx.Err() whenever there were no
resource-specific errors, which incorrectly swallowed context.Canceled
and other non-deadline errors signalling an external interruption.

Refine the condition: only suppress context.DeadlineExceeded when there
are no resource-specific errors (resources are Unknown/NotFound, meaning
the delete wait succeeded or resources were already gone). Any other
context error — including context.Canceled — is always propagated.

Signed-off-by: Terry Howe <terrylhowe@gmail.com>
pull/32081/head
Terry Howe 2 weeks ago
parent 4e24ee41a4
commit 5e09ee78ee
No known key found for this signature in database

@ -160,11 +160,16 @@ func (w *statusWaiter) waitForDelete(ctx context.Context, resourceList ResourceL
errs = append(errs, fmt.Errorf("resource %s/%s/%s still exists. status: %s, message: %s",
rs.Identifier.GroupKind.Kind, rs.Identifier.Namespace, rs.Identifier.Name, rs.Status, rs.Message))
}
// Only include a deadline error when there are also resource-specific errors.
// If all resources are Unknown or NotFound (e.g. deleted before the watch started),
// a timeout is not itself an error for WaitForDelete.
if err := ctx.Err(); err != nil && len(errs) > 0 {
errs = append(errs, err)
if err := ctx.Err(); err != nil {
// context.Canceled and other non-deadline errors always propagate: they signal an
// external interruption regardless of resource state.
// context.DeadlineExceeded is only added when there are resource-specific errors;
// if all resources are Unknown or NotFound the timeout is not itself a failure for
// a delete wait (e.g. resources deleted before the watch started stay Unknown in
// the fake client but are effectively gone).
if !errors.Is(err, context.DeadlineExceeded) || len(errs) > 0 {
errs = append(errs, err)
}
}
if len(errs) > 0 {
return errors.Join(errs...)

Loading…
Cancel
Save