WaitForDelete treated a resource as already gone whenever the kstatus
watcher reported it as Unknown. But the watcher reports Unknown in two
cases: a resource that is genuinely gone, which never emits a delete
event, and a resource that still exists but whose status has not synced
yet. Treating both as deleted let the watch cancel before any real
status arrived, which is the TestStatusWaitForDelete flake in #32261.
The earlier fix for that flake (#32081) deferred that decision, which
made already-gone resources wait the full timeout (the hang in #32214).
It was reverted in v4.2.2, so the flake returned.
Check the cluster directly instead. Before watching, a resource that
returns NotFound from a live GET is already gone and is skipped, and the
observer no longer treats an Unknown status as deleted. Already-gone and
never-created resources, such as before-hook-creation hooks, return
immediately, while a resource that still exists is waited on until it is
actually deleted or the timeout is reached.
closes#32261
refs #32214
refs #32216
Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
w.Logger().Debug("could not check whether resource is deleted, will wait on it","kind",id.GroupKind.Kind,"namespace",id.Namespace,"name",id.Name,"error",err)