-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
✨ client: Add client-wide fieldManager #2771
Conversation
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.
LGTM label has been added. Git tree hash: 1ac0bc513eae0e67430c76c18b160197da20c516
|
[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 |
/cherrypick release-0.17 |
@ahmetb: new pull request created: #2772 In response to this:
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. |
/cherrypick release-0.16 |
@sbueringer: new pull request created: #2775 In response to this:
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 @@ | |||
/* |
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.
@ahmetb Can you please adjust the filename to fieldowner_test.go? (just for main is okay)
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.
sent #2777
// will be overridden. | ||
func WithFieldOwner(c Client, fieldOwner string) Client { | ||
return &clientWithFieldManager{ | ||
manager: fieldOwner, |
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.
nit: Maybe we should call this owner or fieldOwner consistently (compared to manager in one client and owner in the other)
Summary
This PR adds a new
client
functionWithFieldOwner
that wraps aclient.Client
and adds aclient.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.