-
Notifications
You must be signed in to change notification settings - Fork 23
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 metadata watcher and informer #111
Conversation
64b342a
to
962b390
Compare
962b390
to
3fe2e43
Compare
3fe2e43
to
d7f0a73
Compare
Co-authored-by: Mauri de Souza Meneguzzo <[email protected]>
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.
LGTM, thanks!
) (Watcher, error) { | ||
var store cache.Store | ||
var queue workqueue.Interface | ||
var cachedObject runtime.Object | ||
|
||
store = informer.GetStore() | ||
queue = workqueue.NewNamed(name) |
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.
queue = workqueue.NewNamed(name) | |
queue = workqueue.NewWithConfig(QueueConfig{ | |
Name: name, | |
}) |
nit: since you touch this code maybe you wanna deal with deprecated calls as well
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 actually want to avoid touching it as much as possible. I think the recommended way here is to use typed queues, and I don't want to make that kind of change in this PR.
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.
@swiatekm could you make an issue or PR (if it's quicker but I doubt that) to address the deprecated calls? That way we don't lose track of this work. Thanks.
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.
Aside some nitpicking this LGTM
💚 Build Succeeded
History
|
Introduce metadata-only watchers to the kubernetes package. These are useful if we only need to track metadata for a resource - a good example are ReplicaSets, for which we usually only care about the OwnerReferences. As a result, we only store the metadata, reducing steady-state memory consumption, but also only get updates involving metadata, reducing churn greatly in larger clusters.
The implementation introduces new constructors for the Watcher, allowing an informer to be passed in. Existing constructors are implemented using the new constructor, though none of the code actually changes. As a result, it is now possible to unit test the watcher, and I've added some basic unit tests for it.
We also add two helper functions:
GetKubernetesMetadataClient
creates a metadata-only kubernetes client, and is very similar to the existingGetKubernetesClient
RemoveUnnecessaryReplicaSetData
is a transform function that can be passed into an informer so it only stores the metadata we actually useI tested these new functions in both beats and agent, in a kind cluster as well as one of our staging clusters.
This is part of the solution to elastic/elastic-agent#5580.