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

✨ client: Add client-wide fieldManager #2771

Merged

Conversation

ahmetb
Copy link
Member

@ahmetb ahmetb commented Apr 11, 2024

Summary

This PR adds a new client function WithFieldOwner that wraps a client.Client and adds a client.FieldOwner option to all writes from this client. If additional FieldOwner options are specified on methods of this client, the value specified here will be overridden.

Why do we need it?

I have found myself trying to distinguish between different reconcilers in the same controller-manager process for both troubleshooting purposes (i.e having managedFields show the specific controller) and prevent colocated reconcilers from managing the same field.

The alternative was to add client.FieldManager to each individual call, which is tedious and error-prone. Instead, I would prefer to have the client use the same fieldManager across all its write calls.

This PR adds a new `client` function `WithFieldOwner` that wraps a
`client.Client` and adds a `client.FieldOwner` option to all writes
from this client. If additional FieldOwner options are
specified on methods of this client, the value specified here will be
overridden.
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Apr 11, 2024
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 11, 2024
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 11, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 1ac0bc513eae0e67430c76c18b160197da20c516

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ahmetb, vincepri

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 Apr 11, 2024
@k8s-ci-robot k8s-ci-robot merged commit a7508de into kubernetes-sigs:main Apr 11, 2024
9 checks passed
@ahmetb
Copy link
Member Author

ahmetb commented Apr 11, 2024

/cherrypick release-0.17
/cherrypick release-0.16
per @alvaroaleman since it's a net-new change.

@k8s-infra-cherrypick-robot

@ahmetb: new pull request created: #2772

In response to this:

/cherrypick release-0.17
/cherrypick release-0.16
per @alvaroaleman since it's a net-new change.

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.

@sbueringer
Copy link
Member

/cherrypick release-0.16

@k8s-infra-cherrypick-robot

@sbueringer: new pull request created: #2775

In response to this:

/cherrypick release-0.16

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.

@@ -0,0 +1,148 @@
/*
Copy link
Member

Choose a reason for hiding this comment

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

@ahmetb Can you please adjust the filename to fieldowner_test.go? (just for main is okay)

Copy link
Member Author

Choose a reason for hiding this comment

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

sent #2777

// will be overridden.
func WithFieldOwner(c Client, fieldOwner string) Client {
return &clientWithFieldManager{
manager: fieldOwner,
Copy link
Member

Choose a reason for hiding this comment

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

nit: Maybe we should call this owner or fieldOwner consistently (compared to manager in one client and owner in the other)

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. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants