You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 12, 2024. It is now read-only.
context.Background() returns a non-cancellable, empty context, hence passing it to handler func is a no-op.
A map function ideally runs and returns quickly. When using typed generated cache listers, you can traverse from the watch event to whatever you want from the listers without needing a context. But with controller-runtime's Client, you need to pass in a context (and you don't know if you're reading from the cache or using a live client unless you trace the creation of the client you're using).
Let's say instead of context.Background() here, you passed in some cancelable context. Because this call is creating a map function, whatever context you pass in is shared by all invocations of the map function. You can't easily cancel one without canceling all of them (although it's not really clear if we'd want to cancel just one).
The text was updated successfully, but these errors were encountered:
varshaprasad96
changed the title
Propagating context.Background() while watching resources in BundleDeployment reconciler
Passing context.Background() while watching resources in BundleDeployment reconciler
Jan 16, 2024
varshaprasad96
changed the title
Passing context.Background() while watching resources in BundleDeployment reconciler
Passing context.Background() while setting up watches in BundleDeployment reconciler
Jan 16, 2024
Currently, we pass the same context through
context.Background()
in handler funcs while setting up watches in the bundle deployment controller:rukpak/internal/controllers/bundledeployment/bundledeployment.go
Line 114 in 1d284f9
context.Background()
returns a non-cancellable, empty context, hence passing it to handler func is a no-op.A map function ideally runs and returns quickly. When using typed generated cache listers, you can traverse from the watch event to whatever you want from the listers without needing a context. But with controller-runtime's Client, you need to pass in a context (and you don't know if you're reading from the cache or using a live client unless you trace the creation of the client you're using).
Let's say instead of context.Background() here, you passed in some cancelable context. Because this call is creating a map function, whatever context you pass in is shared by all invocations of the map function. You can't easily cancel one without canceling all of them (although it's not really clear if we'd want to cancel just one).
Discussion: #774 (comment)
cc: @ncdc
The text was updated successfully, but these errors were encountered: