Standardize PodDescriber behavior to return NotFound errors consistently
#135281
+0
−27
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
This PR unifies the error handling behavior of
PodDescriberto match all other resource describers.Currently,
PodDescribercontains special-cased logic that attempts to fetch and print events for a deletedPod, but only when triggered via a file (e.g.,kubectl describe -f pod.yaml).This creates an inconsistency:
Standard Behavior: All other describers (and
PodDescribervia direct name/selector) return a standard Error from server (NotFound) when the resource is missing.Inconsistent Behavior:
PodDescribervia -f suppresses the error and attempts to recover events.I have removed the fallback logic that attempts to print events for deleted pods.
PodDescriberwill now consistently return the standard "NotFound" error regardless of how the user queries the resource (-f, name, or --label-selector).Benefits:
Consistency: Aligns
PodDescriberwith the UX of the rest of the CLI.Code Simplification: This simplifies the upcoming refactor to support
runtime.ObjectinResourceDescriber(addressing kubectl describe suffers from N+1 query problem when falling back to prefix search, causing performance issues kubectl#1769). Removing this name/namespace-dependent logic now removes the need to port complex edge-case handling to the parent interface later.Which issue(s) this PR is related to:
kubernetes/kubectl#1769
Does this PR introduce a user-facing change?