Skip to content
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

Merged

Conversation

dixudx
Copy link
Member

@dixudx dixudx commented Jul 25, 2018

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:

kubectl: recreating resources for immutable fields when force is applied

@k8s-ci-robot k8s-ci-robot added 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. kind/bug Categorizes issue or PR as related to a bug. labels Jul 25, 2018
@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jul 25, 2018
@@ -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 {
Copy link
Member

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 :)

Copy link
Member Author

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,

  1. Like you said, for better human readable and code convention.
  2. ReasonForError(nil) will return StatusReasonUnknown, which is not right and confusing. Nil is different from status code 500.

Copy link
Member

Choose a reason for hiding this comment

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

reasonable :)

@juanvallejo
Copy link
Contributor

/lgtm

@dixudx would a small test-cmd test be possible?
cc @soltysh for approval

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 2, 2018
@dixudx
Copy link
Member Author

dixudx commented Aug 7, 2018

/retest

@dixudx dixudx force-pushed the kubectl_apply_force_invalid branch from 987118a to a228b34 Compare August 9, 2018 10:41
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Aug 9, 2018
@dixudx dixudx force-pushed the kubectl_apply_force_invalid branch from a228b34 to 016c9a4 Compare August 9, 2018 13:18
@dixudx dixudx force-pushed the kubectl_apply_force_invalid branch from 016c9a4 to 0af6fae Compare August 9, 2018 14:59
@dixudx
Copy link
Member Author

dixudx commented Aug 9, 2018

@juanvallejo @soltysh Test added. PTAL. Thanks.

Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 10, 2018
@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 10, 2018
@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@k8s-ci-robot
Copy link
Contributor

@dixudx: The following tests failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-kubernetes-integration 0af6fae link /test pull-kubernetes-integration
pull-kubernetes-kubemark-e2e-gce-big 0af6fae link /test pull-kubernetes-kubemark-e2e-gce-big

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.

@k8s-github-robot
Copy link

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.

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. 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. 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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kubectl apply --force does not recreate resources for immutable fields
6 participants