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

Improve kubectl field manager names for clearer conflicts #88885

Merged

Conversation

julianvmodesto
Copy link
Contributor

@julianvmodesto julianvmodesto commented Mar 6, 2020

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

This change improves the kubectl field manager names for clearer conflicts, instead of the default .manager=kubectl.

When an object is managed by server-side apply and has field managers, any kubectl commands will use the same field manager: kubectl. When there is a conflict, then this is confusing because different operations will have the same field manager name. Instead, we can set kubectl subcommands as the field manager name e.g. the manager for kubectl annotate should be kubectl-annotate. This provides a better conflict hint.

For kubectl commands, this change sets the field manager accordingly:

  • kubectl apply has .manager=kubectl-client-side-apply
  • kubectl apply --server-side has .manager=kubectl (remains kubectl instead of kubectl-server-side-apply for backwards compatibility)
  • kubectl annotate has .manager=kubectl-annotate

List of kubectl subcommands updated:

  • annotate
  • apply
  • apply edit-last-applied
  • autoscale
  • cordon
  • create
  • create clusterrole
  • create clusterrolebinding
  • create configmap
  • create cronjob
  • create deployment
  • create job
  • create namespace
  • create poddisruptionbudget
  • create priorityclass
  • create quota
  • create role
  • create rolebinding
  • create secret
  • create service
  • create serviceaccount
  • debug
  • drain
  • edit
  • expose
  • label
  • patch
  • replace
  • rollout pause
  • rollout undo
  • rollout restart
  • rollout resume
  • run
  • set env
  • set image
  • set resources
  • set selector
  • set serviceaccount
  • set subject
  • taint

Which issue(s) this PR fixes:

Related to #80916

Does this PR introduce a user-facing change?:

Improve server-side apply conflict errors by setting dedicated kubectl subcommand field managers

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Mar 6, 2020
@julianvmodesto
Copy link
Contributor Author

/wg apply
cc @seans3
/assign @apelisse
/priority important-soon

@k8s-ci-robot k8s-ci-robot added wg/apply priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Mar 6, 2020
@julianvmodesto
Copy link
Contributor Author

/sig cli

@k8s-ci-robot k8s-ci-robot added sig/cli Categorizes an issue or PR as relevant to SIG CLI. area/kubectl area/test sig/testing Categorizes an issue or PR as relevant to SIG Testing. labels Mar 6, 2020
@julianvmodesto
Copy link
Contributor Author

How does this look? We would add --field-manager to more of the imperative commands where this will be helpful

Copy link
Member

@apelisse apelisse left a comment

Choose a reason for hiding this comment

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

All of this looks great to me (I haven't looked in details). I think this is the right approach, but I suspect we should get approval of sig-cli, maybe through a apply kep update?

@@ -223,6 +223,13 @@ func (o *ApplyOptions) Complete(f cmdutil.Factory, cmd *cobra.Command) error {
}
o.DryRunVerifier = resource.NewDryRunVerifier(o.DynamicClient, discoveryClient)
o.FieldManager = cmdutil.GetFieldManagerFlag(cmd)
if !cmd.Flag("field-manager").Changed {
if o.ServerSideApply {
o.FieldManager = "kubectl-server-side-apply"
Copy link
Member

Choose a reason for hiding this comment

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

does changing the default mean the same kubectl serverside apply operation in subsequent releases would report a conflict with itself?

Copy link
Member

Choose a reason for hiding this comment

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

Yes it does, that's a good point. We probably can't change the "server-side apply" default manager now, kubectl is still a fine name though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ohh I see. Updated to kubectl and added a note about why

@julianvmodesto julianvmodesto force-pushed the kubectl-field-managers branch 2 times, most recently from de80201 to 0d5af2b Compare March 19, 2020 22:47
@julianvmodesto
Copy link
Contributor Author

Okay i'll make a small update to the KEP so we can get feedback from CLI too, and proceed to inventory all of the commands that need to be updated

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 25, 2020
@julianvmodesto julianvmodesto force-pushed the kubectl-field-managers branch 2 times, most recently from f97e078 to d035f84 Compare March 25, 2020 19:42
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 9, 2020
@apelisse
Copy link
Member

/lgtm
/assign @seans3

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 11, 2020
@apelisse
Copy link
Member

/retest

1 similar comment
@seans3
Copy link
Contributor

seans3 commented May 13, 2020

/retest

@seans3
Copy link
Contributor

seans3 commented May 13, 2020

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: julianvmodesto, seans3

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 May 13, 2020
@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

3 similar comments
@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@julianvmodesto
Copy link
Contributor Author

Looks like a flake: #91075

/retest

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

3 similar comments
@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented May 15, 2020

@julianvmodesto: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
pull-kubernetes-node-e2e-containerd d5cc92abfd40ddc63981ed32a173019f46a83f56 link /test pull-kubernetes-node-e2e-containerd

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.

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@k8s-ci-robot k8s-ci-robot merged commit 53a707d into kubernetes:master May 15, 2020
@k8s-ci-robot k8s-ci-robot added this to the v1.19 milestone May 15, 2020
CKchen0726 added a commit to CKchen0726/kubernetes that referenced this pull request Jul 12, 2021
k8s-ci-robot added a commit that referenced this pull request Nov 8, 2021
remove unnecessary function after PR #88885 merged
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 area/test 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. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. 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. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. wg/api-expression Categorizes an issue or PR as relevant to WG API Expression.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants