Kuadrant / policy-machinery

Machinery for implementing Gateway API policies
Apache License 2.0
9 stars 2 forks source link

[controller] Delta reconciliation propagates event twice #23

Closed guicassolato closed 2 months ago

guicassolato commented 2 months ago

Controller runnables based on the IncrementalInformer func ("delta" reconciliation mode) propagate events twice – once synchronously, right after modifying the cache (1), and a second time, async, via subscription to the watchable cache map (2).

  1. create: https://github.com/Kuadrant/policy-machinery/blob/e963418c9566a5e61acdd766c6109d3f0c147222/controller/controller.go#L225 update: https://github.com/Kuadrant/policy-machinery/blob/e963418c9566a5e61acdd766c6109d3f0c147222/controller/controller.go#L237 delete: https://github.com/Kuadrant/policy-machinery/blob/e963418c9566a5e61acdd766c6109d3f0c147222/controller/controller.go#L245

  2. cache subscriber: https://github.com/Kuadrant/policy-machinery/blob/e963418c9566a5e61acdd766c6109d3f0c147222/controller/controller.go#L263

The StateReconciler, on the other hand, does not duplicate events.

Create/update/delete functions of the controller should not propagate the event directly, but let the cache watcher to propagate to the subscriber. As a side effect, due to limitations of telepresenceio/watchable, all update events will be reported as create.