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
Copy file name to clipboardExpand all lines: docs/content/en/docs/documentation/reconciler.md
+40Lines changed: 40 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -210,3 +210,43 @@ called, either by calling any of the `PrimeUpdateAndCacheUtils` methods again or
210
210
updated via `PrimaryUpdateAndCacheUtils`.
211
211
212
212
See related integration test [here](https://github.com/operator-framework/java-operator-sdk/blob/main/operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/statuscache).
213
+
214
+
### Trigger reconciliation on all events
215
+
216
+
TLDR; We provide an execution mode where `reconcile` method is called on every event from event source.
217
+
218
+
The framework optimizes execution for generic use cases, which in almost all cases falls into two categories:
219
+
220
+
1. The controller does not use finalizers; thus when the primary resource is deleted, all the managed secondary
221
+
resources are cleaned up using the Kubernetes garbage collection mechanism, a.k.a., using owner references.
222
+
2. When finalizers are used (using `Cleaner` interface), thus when controller requires some explicit cleanup logic, typically for external
223
+
resources and when secondary resources are in different namespace than the primary resources (owner references
224
+
cannot be used in this case).
225
+
226
+
Note that for example framework neither of those cases triggers the reconciler on the `Delete` event of the primary resource.
227
+
When finalizer is used, it calls `cleaner(..)` method when resource is marked for deletion and our (not other) finalizer
228
+
is present. When there is no finalizer, does not make sense to call the `reconciel(..)` method on a `Delete` event
229
+
since all the cleanup will be done by the garbage collector. This way we spare reconciliation cycles.
230
+
231
+
However, there are cases when controllers do not strictly follow those patterns, typically when:
232
+
- Only some of the primary resources use finalizers, e.g., for some of the primary resources you need
233
+
to create an external resource for others not.
234
+
- You maintain some additional in memory caches (so not all the caches are encapsulated by an `EventSource`)
235
+
and you don't want to use finalizers. For those cases, you typically want to clean up your caches when the primary
236
+
resource is deleted.
237
+
238
+
For such use cases you can set [`triggerReconcilerOnAllEvent`](https://github.com/operator-framework/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/ControllerConfiguration.java#L81)
239
+
to `true`, as a result, `reconcile` method will be triggered on ALL events (so also `Delete` events), and you
240
+
are free to optimize you reconciliation for the use cases above and possibly others.
241
+
242
+
In this mode:
243
+
- you cannot use `Cleaner` interface. The framework assumes you will explicitly manage the finalizers. To
244
+
add finalizer you can use [`PrimeUpdateAndCacheUtils`](https://github.com/operator-framework/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/PrimaryUpdateAndCacheUtils.java#L308).
245
+
- even if the primary resource is already deleted from the Informer's cache, we will still pass the last known state
246
+
as the parameter for the reconciler. You can check if the resource is deleted using `Context.isPrimaryResourceDeleted()`.
247
+
- The retry, rate limiting, re-schedule mechanisms work normally. (The internal caches related to the resource
248
+
are cleaned up only when there was a successful reconiliation after `Delete` event received for the primary resource
249
+
and reconciliation was not re-scheduled.
250
+
- you cannot use managed dependent resources since those manage the finalizers and other logic related to the normal
0 commit comments