Skip to content

Conversation

@scaliby
Copy link
Member

@scaliby scaliby commented Nov 12, 2025

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

This PR unifies the error handling behavior of PodDescriber to match all other resource describers.

Currently, PodDescriber contains special-cased logic that attempts to fetch and print events for a deleted Pod, but only when triggered via a file (e.g., kubectl describe -f pod.yaml).

This creates an inconsistency:

  • Standard Behavior: All other describers (and PodDescriber via direct name/selector) return a standard Error from server (NotFound) when the resource is missing.

  • Inconsistent Behavior: PodDescriber via -f suppresses the error and attempts to recover events.

I have removed the fallback logic that attempts to print events for deleted pods. PodDescriber will now consistently return the standard "NotFound" error regardless of how the user queries the resource (-f, name, or --label-selector).

Benefits:

$ kubectl delete service/my-service
service "my-service" deleted
$ kubectl delete pod/nginx-pod
pod "nginx-pod" deleted
$ kubectl describe service my-service
Error from server (NotFound): services "my-service" not found
$ kubectl describe -f service.yaml 
Error from server (NotFound): services "my-service" not found
$ kubectl describe pod nginx-pod
Error from server (NotFound): pods "nginx-pod" not found
$ kubectl describe -f pod.yaml 
- Pod 'nginx-pod': error 'pods "nginx-pod" not found', but found events.
- Events:
-   Type    Reason     Age   From                                   Message
-   ----    ------     ----  ----                                   -------
+ Error from server (NotFound): pods "nginx-pod" not found

Which issue(s) this PR is related to:

kubernetes/kubectl#1769

Does this PR introduce a user-facing change?

Remove event listing behavior when describing a removed pod from file.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Nov 12, 2025
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Nov 12, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: scaliby
Once this PR has been reviewed and has the lgtm label, please assign apelisse for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added area/kubectl sig/cli Categorizes an issue or PR as relevant to SIG CLI. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Nov 12, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in SIG CLI Nov 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/kubectl cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cli Categorizes an issue or PR as relevant to SIG CLI. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

2 participants