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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃尡Add a Client wrapper that sets the field owner #1474

Closed
wants to merge 1 commit into from

Conversation

bboreham
Copy link
Contributor

This lets us put a meaningful name which shows up as manager in the managedFields of objects.

As used for example at kubernetes-sigs/cluster-api#4428

This lets us put a meaningful name which shows up as `manager`
in the `managedFields` of objects.
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 13, 2021
@k8s-ci-robot
Copy link
Contributor

Hi @bboreham. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: bboreham
To complete the pull request process, please assign shawn-hurley after the PR has been reviewed.
You can assign the PR to them by writing /assign @shawn-hurley in a comment when ready.

The full list of commands accepted by this bot can be found 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 size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Apr 13, 2021
Copy link
Member

@alvaroaleman alvaroaleman left a comment

Choose a reason for hiding this comment

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

Some basic tests would also be good :)
/ok-to-test

@@ -0,0 +1,46 @@
package fieldowner
Copy link
Member

Choose a reason for hiding this comment

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

I think this would be better in pkg/client, ppl might not find it here

}

type clientWithOwner struct {
client.Client
Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer not to embedd the Client, because should we extend the Client in the future with a method that needs wrapping, the clientWithOwner won't do that but the code will still compile.

return c.Client.Update(ctx, obj, append(opts, c.owner)...)
}

func (c *clientWithOwner) Patch(ctx context.Context, obj client.Object, patch client.Patch, opts ...client.PatchOption) error {
Copy link
Member

Choose a reason for hiding this comment

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

Delete doesn't need it? I intuitively would have expected Delete to make you owner of metadata.DeletionTimestamp (but haven't actually checked)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, me too, but the FieldOwner type does not coerce to a DeleteOption.

I wonder if @DirectXMan12 who seems to have authored that in #435 has a view?

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 14, 2021
Copy link
Contributor

@JoelSpeed JoelSpeed left a comment

Choose a reason for hiding this comment

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

Based off of this and some of the comments @alvaroaleman made, I was wondering about whether we could look at extending the Client itself with a WithOpts(opts ...interace{}) Client kind of method that would allow the client to store options and add the options to every request where the provided option coerces to the correct kind of option?

That would be more generic and would allow you to use this for other things, eg you could create a DryRun client by adding the DryRun option

@bboreham
Copy link
Contributor Author

Thanks for joining the discussion; it's a point I had not considered.

add the options to every request where the provided option coerces to the correct kind of option

That sort of interface will quietly do nothing if you set things up wrongly, which is unpleasant to debug.
It doesn't seem a huge win to me as many options are quite case-specific, e.g. PropagationPolicy or Preconditions.

I'm not averse to adding DryRunAll on the same level as FieldOwner.

@JoelSpeed
Copy link
Contributor

That sort of interface will quietly do nothing if you set things up wrongly, which is unpleasant to debug.

Yeah that's a very good point 馃

It doesn't seem a huge win to me as many options are quite case-specific, e.g. PropagationPolicy or Preconditions.

I just had a look and I think you're right, there isn't much value in the generic option wrapper at the moment, it wouldn't be that useful apart from field owner and dry run (maybe useful for other options in the future but let's not prematurely optimise).

@alvaroaleman
Copy link
Member

That would be more generic and would allow you to use this for other things, eg you could create a DryRun client by adding the DryRun option

We already have a wrapper for DryRun and for Namespacing. Building a generic wrapper that takes an option and maybe uses type assertions to apply them as applicable sounds like a good idea to me. We could probably then replace the existing DryRun wrapper and this new Field wrapper with a constructor to this generic implementation.

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 13, 2021
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Aug 12, 2021
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue or PR with /reopen
  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

@k8s-ci-robot
Copy link
Contributor

@k8s-triage-robot: Closed this PR.

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue or PR with /reopen
  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

None yet

6 participants