Skip to content

Commit 03410ae

Browse files
committed
docs: improve wording
1 parent c4b5371 commit 03410ae

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

docs/content/en/docs/documentation/reconciler.md

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -211,43 +211,50 @@ updated via `PrimaryUpdateAndCacheUtils`.
211211

212212
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).
213213

214-
### Trigger reconciliation on all events
214+
### Trigger reconciliation even for `Delete` events
215215

216216
TLDR; We provide an execution mode where `reconcile` method is called on every event from event source.
217217

218-
The framework optimizes execution for generic use cases, which in almost all cases falls into two categories:
218+
The framework optimizes execution for generic use cases, which, in almost all cases, fall into two categories:
219219

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).
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. This
222+
mechanism, however, only works when all secondary resources are Kubernetes resources in the same namespace as the
223+
primary resource.
224+
2. The controller uses finalizers (the controller implements the `Cleaner` interface), when explicit cleanup logic is
225+
required, typically for external resources and when secondary resources are in different namespace than the primary
226+
resources (owner references cannot be used in this case).
225227

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.
228+
Note that neither of those cases trigger the `reconcile` method of the controller on the `Delete` event of the primary
229+
resource. When a finalizer is used, the SDK calls the `cleanup` method of the `Cleaner` implementation when the resource
230+
is marked for deletion and the finalizer specified by the controller is present on the primary resource. When there is
231+
no finalizer, there is no need to call the `reconcile` method on a `Delete` event since all the cleanup will be done by
232+
the garbage collector. This avoids reconciliation cycles.
230233

231234
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
235+
236+
- Only some of the primary resources use finalizers, e.g., for some of the primary resources you need
233237
to create an external resource for others not.
234238
- You maintain some additional in memory caches (so not all the caches are encapsulated by an `EventSource`)
235239
and you don't want to use finalizers. For those cases, you typically want to clean up your caches when the primary
236240
resource is deleted.
237241

238242
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.
243+
to `true`, as a result, the `reconcile` method will be triggered on ALL events (so also `Delete` events), making it
244+
possible to support the above use cases.
241245

242246
In this mode:
247+
243248
- even if the primary resource is already deleted from the Informer's cache, we will still pass the last known state
244-
as the parameter for the reconciler. You can check if the resource is deleted using `Context.isPrimaryResourceDeleted()`.
245-
- The retry, rate limiting, re-schedule, filters mechanisms work normally. (The internal caches related to the resource
246-
are cleaned up only when there was a successful reconiliation after `Delete` event received for the primary resource
247-
and reconciliation was not re-scheduled.
248-
- you cannot use `Cleaner` interface. The framework assumes you will explicitly manage the finalizers. To
249-
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).
249+
as the parameter for the reconciler. You can check if the resource is deleted using
250+
`Context.isPrimaryResourceDeleted()`.
251+
- The retry, rate limiting, re-schedule, filters mechanisms work normally. The internal caches related to the resource
252+
are cleaned up only when there is a successful reconciliation after a `Delete` event was received for the primary
253+
resource
254+
and reconciliation is not re-scheduled.
255+
- you cannot use the `Cleaner` interface. The framework assumes you will explicitly manage the finalizers. To
256+
add finalizer you can use [
257+
`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).
250258
- you cannot use managed dependent resources since those manage the finalizers and other logic related to the normal
251259
execution mode.
252260

253-

0 commit comments

Comments
 (0)