-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
resource: Make the resource lazy by default #21862
Conversation
The practical use-case for this is: https://github.com/cilium/cilium/pull/21764/files#r1003189088 |
6569f3e
to
ab488d9
Compare
@@ -135,9 +143,34 @@ func (r *resource[T]) pushDelete(lastState any) { | |||
} | |||
|
|||
func (r *resource[T]) Start(startCtx hive.HookContext) error { | |||
r.wg.Add(1) |
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.
Do we even really need Start() anymore?
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 still want this to wait until being told to start, e.g. we don't want "cilium-agent objects" inspection to actually start pulling data from api-server, and I don't see any reason to forbid Observe
calls from constructors.
ab488d9
to
a1ecd6e
Compare
For some resource kinds we only have observers if a feature has been enabled. Rather than guarding the creating of resource based on a set of "enabled" flags, make the resource lazy and only start the informer when the first observer (or call to Store()) is seen. Signed-off-by: Jussi Maki <jussi@isovalent.com>
a1ecd6e
to
ce61e71
Compare
|
For some resource kinds we only have observers if a feature has been enabled. Rather than guarding the creating of resource based on a set of "enabled" flags, make the resource lazy and only start the informer when the first observer (or call to Store()) is seen.