pkg/drain: Provide hooks for intermediate eviction errors #1582
Labels
kind/feature
Categorizes issue or PR as related to a new feature.
sig/cli
Categorizes an issue or PR as relevant to SIG CLI.
triage/accepted
Indicates an issue or PR is ready to be actively worked on.
What would you like to be added
Currently https://pkg.go.dev/k8s.io/kubectl/pkg/drain offers hooks that callers can use to get notified when a Pod eviction is starting or finished. For example:
This method signature (and Godoc) made me think my code will get intermediate errors in the
err
variable that I can use to make decisions, or print progress.However, that did not turn out to be the case.
Currently, the
OnPodDeletionOrEvictionFinished()
is only called when:Evict
orDelete Pod
call succeeded + polling for Pod to be deleted succeeds.Evict
orDelete Pod
call succeeded + there was an error in polling for waiting Pod to be fully deleted.Proposal
Extend the semantics around
OnPodDeletionOrEvictionFinished()
hook to include intermediate errors.Why is this needed
If my code gets an
err
that is ofcode=429
(indicating PDB disallowing eviction), I cancancel()
thectx
I passed toRunNodeDrain(ctx)
, because waiting for many more minutes and retrying in 5s likely won't fix the issue.The documentation of
OnPodDeletionOrEvictionFinished()
hook saysfor printing progress output
. However, if the drain operation is currently failing due to a single Pod refusing to Evict (say, due to PDB), this can provide the callers with an option to print progressCurrently, this hook only works for printing progress if the eviction is successful, which makes it basically the same as
OnPodDeletedOrEvicted func(pod *corev1.Pod, usingEviction bool)
hook./kind feature
/sig cli
/cc @adilGhaffarDev
/cc soltysh
The text was updated successfully, but these errors were encountered: