vmware-labs / reconciler-runtime

⚠️ Maintenance suspended. Please, migrate to the active fork reconciler.io/runtime. See https://github.com/reconcilerio/runtime/releases/tag/v0.20.0 for instructions. This repository will be archived eventually.
Other
82 stars 18 forks source link

Tracker watching dynamic resource types #84

Open Samze opened 3 years ago

Samze commented 3 years ago

Hey Scott,

Something we have done a bunch of times using regular controller-runtime tooling is to setup watches for resources that arn't known about upfront. For example, we might have a CRD that allows for a resource GVK to be defined in the spec, so someone creates a CR configured for the RMQ resource and our controller will inspect that, perhaps create some RMQ resources and want to watch for changes.

It looks like the Tracker object can setup watches dynamically but only if the type is known upfront, as it stands requires a bldr.Watch call in the Setup of the Reconciler, is that correct?

Cheers, Sam

scothis commented 3 years ago

There's active work in this space. Check out #65.

If that PR fits your needs, we can work to get it merged. The main open issue at the moment is that when we start tracking a new resource, we start an informer which is never stoped until the process terminates. If the set of kinds being watched is stable this isn't an issue, but it can cause additional memory to be consumed to maintain informer caches for resources that aren't actually doing anything.

Samze commented 3 years ago

Ah I totally didn't see that, thanks.

Yes, that PR would fit the use case I'm describing. We have some existing components that fit this pattern, so we're not in any sort of hurry - but it would be a useful feature for us writing new reconcilers in the future.

For us, the set of Kinds are fairly dynamic. New CRDs are created at runtime, and watched by our components - however we're not really that concerned with optimisation right now, so if there was a memory leak of informer cache it wouldn't stop us adopting the feature.