Skip to content

Commit b05881c

Browse files
committed
Revert "fix(kube): prevent spurious early exit in WaitForDelete during informer sync"
Signed-off-by: George Jenkins <[email protected]>
1 parent d591a19 commit b05881c

1 file changed

Lines changed: 1 addition & 19 deletions

File tree

pkg/kube/statuswait.go

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,7 @@ func (w *statusWaiter) waitForDelete(ctx context.Context, resourceList ResourceL
161161
rs.Identifier.GroupKind.Kind, rs.Identifier.Namespace, rs.Identifier.Name, rs.Status, rs.Message))
162162
}
163163
if err := ctx.Err(); err != nil {
164-
// context.Canceled and other non-deadline errors always propagate: they signal an
165-
// external interruption regardless of resource state.
166-
// context.DeadlineExceeded is only added when there are resource-specific errors;
167-
// if all resources are Unknown or NotFound the timeout is not itself a failure for
168-
// a delete wait (e.g. resources deleted before the watch started stay Unknown in
169-
// the fake client but are effectively gone).
170-
if !errors.Is(err, context.DeadlineExceeded) || len(errs) > 0 {
171-
errs = append(errs, err)
172-
}
164+
errs = append(errs, err)
173165
}
174166
if len(errs) > 0 {
175167
return errors.Join(errs...)
@@ -242,15 +234,13 @@ func statusObserver(cancel context.CancelFunc, desired status.Status, logger *sl
242234
return func(statusCollector *collector.ResourceStatusCollector, _ event.Event) {
243235
var rss []*event.ResourceStatus
244236
var nonDesiredResources []*event.ResourceStatus
245-
var unknownSkipped int
246237
for _, rs := range statusCollector.ResourceStatuses {
247238
if rs == nil {
248239
continue
249240
}
250241
// If a resource is already deleted before waiting has started, it will show as unknown.
251242
// This check ensures we don't wait forever for a resource that is already deleted.
252243
if rs.Status == status.UnknownStatus && desired == status.NotFoundStatus {
253-
unknownSkipped++
254244
continue
255245
}
256246
// Failed is a terminal state. This check ensures we don't wait forever for a resource
@@ -264,14 +254,6 @@ func statusObserver(cancel context.CancelFunc, desired status.Status, logger *sl
264254
}
265255
}
266256

267-
// During informer initialization there is a brief window where existing resources
268-
// appear as Unknown before their real status is delivered. If every resource was
269-
// skipped as Unknown, we cannot yet distinguish "all deleted" from "not yet synced",
270-
// so hold off on the early-cancel to avoid a spurious success or premature exit.
271-
if unknownSkipped > 0 && len(rss) == 0 {
272-
return
273-
}
274-
275257
if aggregator.AggregateStatus(rss, desired) == desired {
276258
logger.Debug("all resources achieved desired status", "desiredStatus", desired, "resourceCount", len(rss))
277259
cancel()

0 commit comments

Comments
 (0)