Skip to content

Improve ignore-not-found behavior - #132542

Merged
k8s-ci-robot merged 2 commits into
kubernetes:masterfrom
gemmahou:ignorenotfound
Jul 3, 2025
Merged

k8s-ci-robot merged 2 commits into
kubernetes:masterfrom
gemmahou:ignorenotfound

Conversation

@gemmahou

@gemmahou gemmahou commented Jun 25, 2025 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  1. Improve help message of ignore-not-found flag

before:

--ignore-not-found=false:
	If the requested object does not exist the command will return exit code 0.

after:

--ignore-not-found=false:
    If set to true, suppresses NotFound error for object(s) that do not exist and returns exit code 0. Using this flag with commands that query for collections of resources has no effect on the exit code.
  1. Check ignore-not-found flag in watch operation as well; when it's set to true, ignore errors
  2. Improve test coverage

/kind bug

What this PR does / why we need it:

Which issue(s) this PR is related to:

kubernetes/kubectl#1596

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Yes

     Clarify help message of --ignore-not-found flag. Support --ignore-not-found in `watch` operation.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. 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. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 25, 2025
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

Hi @gemmahou. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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 needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/kubectl sig/cli Categorizes an issue or PR as relevant to SIG CLI. labels Jun 25, 2025
@github-project-automation github-project-automation Bot moved this to Needs Triage in SIG CLI Jun 25, 2025
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Jun 25, 2025
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jun 25, 2025
@gemmahou

Copy link
Copy Markdown
Contributor Author

/assign @seans3

@seans3

seans3 commented Jun 26, 2025

Copy link
Copy Markdown
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 26, 2025
@seans3

seans3 commented Jun 26, 2025

Copy link
Copy Markdown
Contributor

/triage accepted
/priority backlog

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. priority/backlog Higher priority than priority/awaiting-more-evidence. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Jun 26, 2025

@seans3 seans3 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, and thanks for the tests. But if I understood the conversation in this issue correctly, I believe there should also be a warning if the --ignore-not-found flag is set when not getting a specific resource. In other words, it doesn't make sense to set the flag unless also retrieving a specific resource. Please let me know what you think.

@brianpursley

Copy link
Copy Markdown
Member

/hold
for further discussion regarding the warning.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 2, 2025
@gemmahou

gemmahou commented Jul 2, 2025 •

Copy link
Copy Markdown
Contributor Author

/hold for further discussion regarding the warning.

Thanks @brianpursley for your review! I got some clarifications to your comments, and I agree that if the warning is confusing for us as developers, it will likely further confuse our users. I agree we should hold off on implementing the warning message for now, unless we can find a clearer way to present it to users.

Regarding your 2nd option: Only print the warning when you are NOT attempting to get a specific resource by name, and the warning would basically be "warning: --ignore-not-found has no effect".

I believe @seans3 suggested the same earlier and I replied in this comment why I did not implement that way, I appreciate your thoughts/comments on this.

Update: I reverted the warning commit in this PR and cherry-picked it to draft PR: #132690 for visibility and further discussion.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 2, 2025
@k8s-ci-robot
k8s-ci-robot requested a review from seans3 July 2, 2025 18:15

@brianpursley brianpursley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks!

/unhold
/lgtm
/approve

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 2, 2025
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 2, 2025
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

LGTM label has been added.

DetailsGit tree hash: 3377cb6e49bd13ecfadd895f526bb02880bc9d28

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: brianpursley, gemmahou, seans3

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

The pull request process is described here

Details 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

@brianpursley

Copy link
Copy Markdown
Member

/label tide/merge-method-squash

@k8s-ci-robot k8s-ci-robot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Jul 2, 2025
@brianpursley

Copy link
Copy Markdown
Member

/retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/kubectl cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/backlog Higher priority than priority/awaiting-more-evidence. 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/L Denotes a PR that changes 100-499 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants