-
Notifications
You must be signed in to change notification settings - Fork 38.8k
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
dynamic informer factory #69308
dynamic informer factory #69308
Conversation
/assign @deads2k |
} | ||
|
||
// Start initializes all requested informers. | ||
// TODO: accept context ? |
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.
wdyt ?
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.
No context. The start should be consistent with the normal SharedInformerFactory
. It may be helpful to make an interface that contains both. It would have
- start
- waitforcachesync
- forresource
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.
We would have to create a new interface that would contain methods that accept the context. Golang doesn't support method overloading :)
f.lock.Lock() | ||
defer f.lock.Unlock() | ||
|
||
// TODO: do we want to format the keys ? |
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.
to make debugging more informative, especially when using WaitForCacheSync
rather than printing something like /v1, Resources=pod
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.
to make debugging more informative, especially when using
WaitForCacheSync
rather than printing something like/v1, Resources=pod
I would key on the natural gvr and then coerce the display however we like
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.
oh, good idea.
} | ||
|
||
// NewFilteredDynamicInformer constructs a new informer for a dynamic type. | ||
func NewFilteredDynamicInformer(client dynamic.Interface, gvr schema.GroupVersionResource, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions TweakListOptionsFunc) informers.GenericInformer { |
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.
should this method be public ?
should this method return GenericInformer
?
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.
should this method be public ?
should this method returnGenericInformer
?
this looks reasonable.
WaitForCacheSync(stopCh <-chan struct{}) map[string]bool | ||
} | ||
|
||
type TweakListOptionsFunc func(*metav1.ListOptions) |
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.
are you okay with defining this func here ?
I think it is already defined somewhere here k8s.io/client-go/informers/internalinterfaces
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.
are you okay with defining this func here ?
I think it is already defined somewhere herek8s.io/client-go/informers/internalinterfaces
Yes, we want to keep this here. Eventually we are likely to need to snip the links to the typed clients.
@deads2k waiting for your feedback before adding some tests. |
namespace string | ||
|
||
lock sync.Mutex | ||
informers map[string]informers.GenericInformer |
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.
I expected a GVR
|
||
// New returns a new shim for Lister. | ||
// It wraps Lister so that it implements cache.GenericLister interface | ||
func NewShim(lister Lister) cache.GenericLister { |
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.
NewRuntimeObjectShim
?
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.
np
This looks really good. Have you been able to think of a good way to test it? |
not much, but I expect it will be messy, I think the flow will be:
|
/cc @yliaog |
/lgtm /hold holding for the test. |
b544571
to
0b63464
Compare
0b63464
to
48a8d29
Compare
added missing test, PTAL |
48a8d29
to
d3dc9c5
Compare
the commit "adds dynamic lister" 5c9261294cbcf1e2daab5719bbc8b4cd4dcd0a6c could be removed |
d3dc9c5
to
4d479af
Compare
/lgtm @p0lyn0mial great job. |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: deads2k, p0lyn0mial 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 |
/kind feature |
/test pull-kubernetes-e2e-kops-aws |
What this PR does / why we need it: adds dynamic informer factory
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged): #64319Special notes for your reviewer:
Release note: