-
Notifications
You must be signed in to change notification settings - Fork 39.8k
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
kubectl: recreating resources for immutable fields when force is applied #66602
kubectl: recreating resources for immutable fields when force is applied #66602
Conversation
@@ -753,7 +753,7 @@ func (p *patcher) patch(current runtime.Object, modified []byte, source, namespa | |||
} | |||
patchBytes, patchObject, err = p.patchSimple(current, modified, source, namespace, name, errOut) | |||
} | |||
if err != nil && errors.IsConflict(err) && p.force { | |||
if err != nil && (errors.IsConflict(err) || errors.IsInvalid(err)) && p.force { |
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.
super nit: @dixudx how do you think about pruing err != nil
here? it might be unneccesary to do the nil value check here because neither IsConflict
or IsInvalid
would return true on a nil error AFAICT. Not really sure if the additional judge here is for a better human-read :)
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.
@yue9944882 Although both IsConflict
and IsInvalid
return False
for nil.(Type)
, I'd prefer to keep it for several reasons,
- Like you said, for better human readable and code convention.
ReasonForError(nil)
will returnStatusReasonUnknown
, which is not right and confusing.Nil
is different from status code 500.
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.
reasonable :)
/retest |
987118a
to
a228b34
Compare
a228b34
to
016c9a4
Compare
016c9a4
to
0af6fae
Compare
@juanvallejo @soltysh Test added. PTAL. Thanks. |
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
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dixudx, 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] |
@dixudx: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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/test-infra repository. I understand the commands that are listed here. |
Automatic merge from submit-queue (batch tested with PRs 66602, 67178, 67207, 67125, 66332). If you want to cherry-pick this change to another branch, please follow the instructions here. |
What this PR does / why we need it:
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #66390
Special notes for your reviewer:
/assign soltysh juanvallejo
/cc @kubernetes/sig-cli-bugs
Release note: