Skip to content

Commit 31c1218

Browse files
authored
Update reconciler.md
1 parent a4c5f3c commit 31c1218

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

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

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,21 @@ Once the reconciliation is done, the framework checks if:
2727
In summary, the core of the SDK is implemented as an eventing system where events trigger
2828
reconciliation requests.
2929

30-
## Implementing a [`Reconciler`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/Reconciler.java) and/or [`Cleaner`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/Cleaner.java)
30+
## Implementing a Reconciler and Cleaner interfaces
3131

32-
The lifecycle of a Kubernetes resource can be separated into two phases depending on weather the resource is already marked for deletion or not.
32+
To implement a reconciler, you always have to implement the [`Reconciler`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/Reconciler.java) interface.
33+
34+
The lifecycle of a Kubernetes resource can be separated into two phases depending on whether the resource has already been marked for deletion or not.
3335

3436
The framework out of the box supports this logic, it will always
3537
call the `reconcile` method unless the custom resource is
36-
[marked from deletion](https://kubernetes.io/docs/concepts/overview/working-with-objects/finalizers/#how-finalizers-work)
37-
. On the other, if the resource is marked from deletion and if the `Reconciler` implements the
38-
`Cleaner` interface, only the `cleanup` method is called. By implementing the `Cleaner`
38+
[marked from deletion](https://kubernetes.io/docs/concepts/overview/working-with-objects/finalizers/#how-finalizers-work).
39+
40+
On the other, if the resource is marked from deletion and if the `Reconciler` implements the
41+
[`Cleaner`](https://github.com/operator-framework/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/Cleaner.java) interface, only the `cleanup` method is called. By implementing the `Cleaner`
3942
the framework will automatically handle (add/remove) the finalizers for you.
4043

41-
See [Finalizer support](#finalizer-support) for more details.
44+
In short, if you need to provide explicit cleanup logic, you always want to use finalizers; for a more detailed explanation, see [Finalizer support](#finalizer-support) for more details.
4245

4346
### Using `UpdateControl` and `DeleteControl`
4447

@@ -133,32 +136,30 @@ Kubernetes cluster (e.g. external resources), you might not need to use finalize
133136
use the
134137
Kubernetes [garbage collection](https://kubernetes.io/docs/concepts/architecture/garbage-collection/#owners-dependents)
135138
mechanism as much as possible by setting owner references for your secondary resources so that
136-
the cluster can automatically deleted them for you whenever the associated primary resource is
139+
the cluster can automatically delete them for you whenever the associated primary resource is
137140
deleted. Note that setting owner references is the responsibility of the `Reconciler`
138141
implementation, though [dependent resources](https://javaoperatorsdk.io/docs/dependent-resources)
139142
make that process easier.
140143

141-
If you do need to clean such state, you need to use finalizers so that their
144+
If you do need to clean such a state, you need to use finalizers so that their
142145
presence will prevent the Kubernetes server from deleting the resource before your operator is
143-
ready to allow it. This allows for clean up to still occur even if your operator was down when
144-
the resources was "deleted" by a user.
146+
ready to allow it. This allows for clean-up even if your operator was down when the resource was marked for deletion.
145147

146148
JOSDK makes cleaning resources in this fashion easier by taking care of managing finalizers
147149
automatically for you when needed. The only thing you need to do is let the SDK know that your
148-
operator is interested in cleaning state associated with your primary resources by having it
150+
operator is interested in cleaning the state associated with your primary resources by having it
149151
implement
150152
the [`Cleaner<P>`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/Cleaner.java)
151153
interface. If your `Reconciler` doesn't implement the `Cleaner` interface, the SDK will consider
152-
that you don't need to perform any clean-up when resources are deleted and will therefore not
153-
activate finalizer support. In other words, finalizer support is added only if your `Reconciler`
154-
implements the `Cleaner` interface.
154+
that you don't need to perform any clean-up when resources are deleted and will, therefore, not activate finalizer support.
155+
In other words, finalizer support is added only if your `Reconciler` implements the `Cleaner` interface.
155156

156-
Finalizers are automatically added by the framework as the first step, thus after a resource
157-
is created, but before the first reconciliation. The finalizer is added via a separate
157+
The framework automatically adds finalizers as the first step, thus after a resource
158+
is created but before the first reconciliation. The finalizer is added via a separate
158159
Kubernetes API call. As a result of this update, the finalizer will then be present on the
159160
resource. The reconciliation can then proceed as normal.
160161

161-
The finalizer that is automatically added will be also removed after the `cleanup` is executed on
162+
The automatically added finalizer will also be removed after the `cleanup` is executed on
162163
the reconciler. This behavior is customizable as explained
163164
[above](#using-updatecontrol-and-deletecontrol) when we addressed the use of
164165
`DeleteControl`.
@@ -167,4 +168,4 @@ You can specify the name of the finalizer to use for your `Reconciler` using the
167168
[`@ControllerConfiguration`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/ControllerConfiguration.java)
168169
annotation. If you do not specify a finalizer name, one will be automatically generated for you.
169170

170-
From v5 by default finalizer is added using Served Side Apply. See also UpdateControl in docs.
171+
From v5, by default, the finalizer is added using the Served Side Apply. See also UpdateControl in docs.

0 commit comments

Comments
 (0)