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

⚠ Add manager option to enable caching of unstructured objects #1338

Conversation

joelanford
Copy link
Member

This PR adds a new manager/cluster option, called ClientCacheUnstructured that configures the ClientBuilder to build a client that caches unstructured objects.

It is a breaking change because it requires a new method on the cluster.ClientBuilder interface.

This is a follow-up based on #1332 (comment)

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jan 14, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: joelanford

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 approved Indicates a PR has been approved by an approver from all required OWNERS files. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jan 14, 2021
@joelanford
Copy link
Member Author

/hold

For more discussion since this is a breaking change.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 14, 2021
@joelanford joelanford force-pushed the feat/manager-opt-unstruct-cache branch from 5c4ad30 to 6526b3a Compare January 14, 2021 18:44
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jan 14, 2021
@joelanford
Copy link
Member Author

/retest

@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Jan 14, 2021

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

Test name Commit Details Rerun command
pull-controller-runtime-apidiff-master 6526b3a link /test pull-controller-runtime-apidiff-master

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.

@vincepri
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 14, 2021
@shawn-hurley
Copy link

Could another approach be to make a new client.Option for this and that would not be a breaking change I think?

I am not saying we should just wondering if we looked at that approach.

@joelanford
Copy link
Member Author

joelanford commented Jan 14, 2021

@shawn-hurley I'm not following your suggestion. I was also trying to think of a non-breaking change approach, but nothing is coming to me that would make this option available to arbitrary ClientBuilders.

IMO, it's a little bit odd that we would have cache-related methods on the ClientBuilder interface because it implies that all clients need to handle caching. We do pass a cache as a Build() parameter, but that could theoretically be ignored. Cache-specific methods on the interface for non-caching implementations would need to be no-ops.

I suppose we could make a new interface CachingClientBuilder like below and then do type assertions to see if we can call some extra methods:

type CachingClientBuilder interface {
	ClientBuilder
	WithUncached(objs ...client.Object) ClientBuilder
	CacheUnstructured(v bool) ClientBuilder
}

But even with that approach, @estroz made the astute observation that further configurations that affect the delegatingClient would require further breaking changes on this interface if we wanted to expose that configuration to users.

@shawn-hurley
Copy link

Admittedly, have not been involved enough over the last year to know if this makes sense so if it doesn't I am sorry :).

I was wondering if it could be a option here:
https://github.com/kubernetes-sigs/controller-runtime/blob/master/pkg/client/client.go#L37

such that at ClientBuilder.Build it is passed in as an option for the client.

Maybe this doesn't make sense because the ClientBuilder already handles caching concerns and the Options don't so maybe this is a bad idea :)

@k8s-ci-robot
Copy link
Contributor

@joelanford: PR needs rebase.

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 k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 6, 2021
@huozby
Copy link

huozby commented Apr 14, 2021

I'm quite confused about manager option(filed ClientBuilder -> filed NewClient) in release v0.8.3 and v0.9.0.alpha1. Why the6. field fallback to release v0.6.5. Could someone explain it? Which version should I use when I write my own controller...

@joelanford
Copy link
Member Author

@hzbcloud #1332 highlights the regression caused by the change to ClientBuilder and #1409 makes the change back to NewClientFunc. These PRs should explain why we needed to revert the ClientBuilder option.

Closing this since the problem this PR solves is no longer a problem with NewClientFunc.

@joelanford joelanford closed this Apr 27, 2021
@joelanford joelanford deleted the feat/manager-opt-unstruct-cache branch April 27, 2021 00:58
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. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. 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

5 participants