-
Notifications
You must be signed in to change notification settings - Fork 40k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update exit code to 0 if patch not needed #66725
update exit code to 0 if patch not needed #66725
Conversation
/sig cli |
@@ -245,14 +245,8 @@ func (o *PatchOptions) RunPatch() error { | |||
if err != nil { | |||
return err | |||
} | |||
printer.PrintObj(info.Object, o.Out) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add a tests verifying:
- that exit code is 0, when the patch was empty
- that exit code is non-zero, when the patch command actually failed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@soltysh Added a test. Although I realize after adding it, that only semantic or type errors will result in the error being printed out and an exit code of 1. If someone were to, for example, update an immutable field on a pod, or set a value for a non-existent spec field on a pod (like replicas), the server would just return the old object with no error, and the command would exit with the message "not patched" (as before), but with exit code 0 (since the old and new object were the same)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's reasonable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
Please squash your changes into single commit and I push this forward.
91c0f0d
to
578ab90
Compare
/test pull-kubernetes-integration |
578ab90
to
ad11a1b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: juanvallejo, soltysh The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/test all [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here. |
Release note:
The specific logic in the
patch
command that exited with code 1, was only doing so when there was no diff between an existing object and its patched counterpart. (In case of errors, we just return those, which eventually ends up exiting with code 1 anyway). This patch removes this block, as we should not be treating patch no-ops as errors.Fixes #58212
cc @soltysh