Skip to content
This repository has been archived by the owner on Aug 12, 2024. It is now read-only.

Passing context.Background() while setting up watches in BundleDeployment reconciler #799

Closed
varshaprasad96 opened this issue Jan 16, 2024 · 1 comment

Comments

@varshaprasad96
Copy link
Member

Currently, we pass the same context through context.Background() in handler funcs while setting up watches in the bundle deployment controller:

util.MapBundleToBundleDeploymentHandler(context.Background(), mgr.GetClient(), c.provisionerID)),

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

@varshaprasad96 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 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
@joelanford
Copy link
Member

Fixed by #794

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants