-
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
Define a supported way of setting a cache on source.Kind #650
Comments
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
We are interested to use controller-runtime in a scenario involving multiple api-servers/clusters (see #745) and this issue looks like a first step towards multi-cluster support. Is there anything we could do to drive this forward? |
/remove-lifecycle stale |
Mainly just figure out which option looks the best here with a little proposal (nothing super long, just like a paragraph in this issue) and then implement it ;-) |
I am in favor of just documenting and testing the current approach, the two other options are IMHO inferior:
This would extend the API needlessly.
This would extend the API needlessly and be super confusing in our code, because the new Godoc change for the first option could look something like this: @@ -55,7 +55,9 @@ type Source interface {
Start(handler.EventHandler, workqueue.RateLimitingInterface, ...predicate.Predicate) error
}
-// Kind is used to provide a source of events originating inside the cluster from Watches (e.g. Pod Create)
+// Kind is used to provide a source of events originating inside the cluster from Watches (e.g. Pod Create).
+// It can be used to watch objects in a different cluster by calling its InjectCache method with the cache
+// from that other cluster.
type Kind struct {
// Type is the type of object to watch. e.g. &v1.Pod{}
Type runtime.Object @DirectXMan12 There is no proposal process for c-r documented (that I can find). Is the outline in this comment enough or do you want a PR that adds it to the repo? |
@alvaroaleman How about a more explicit solution than "just" documenting the behaviour. How about a wrapper similar to f7d3056 (just a quick first draft). I think it is not possible to use this wrapper in a wrong way and we don't rely on the current undocumented behaviour of func CreateSourceWithFixedCache(object runtime.Object, cache cache.Cache) Source {
return &sourceWithFixedCache{kind: Kind{Type: object, cache: cache}}
}
type sourceWithFixedCache struct {
kind Kind
} @DirectXMan12 What do you think of this? |
Sounds good to me as well. I am mostly concerned about the question if this will be intuitive, because in the local cluster case the source is called
Well, the missing documentation can be added :) I do not have a strong opinion on either of the two, but having anything that is officially supported would be great |
The more explicit type I think seems slightly better to me |
+1 for more explicit, The implicit method is harder to rationalize about without understanding the implementation. |
In order to be able to write a controller that has informers in multiple clusters, one has to inject a cache into
source.Kind
. Options to do this include:kind.InjectCache
, it has a nilcheck that will prevent theinjectCache
call from the controller to overwrite the cache. However this behavior doesn't have tests and may go away in the futurekind.Source
that implementsInjectCache
with the nilcheckkind.Source
that does not implementinject.Cache
We should agree on one option, declare it the supported way to build multicluster controllers and probably document it.
The text was updated successfully, but these errors were encountered: