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
make sure that a reconciliation happens when a custom resource is instructed to be deleted. Typical case when it's
39
39
useful, when an operator is down (pod not running). Without a finalizer the reconciliation - thus the cleanup -
40
-
i.e. [`Reconciler.cleanup(...)`](https://github.com/java-operator-sdk/java-operator-sdk/blob/b91221bb54af19761a617bf18eef381e8ceb3b4c/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/Reconciler.java#L31)
40
+
i.e. [`Cleaner.cleanup(...)`](https://github.com/java-operator-sdk/java-operator-sdk/blob/b82c1f106968cb3eb18835c5e9cd1e4d5c40362e/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/Cleaner.java#L28-L28)
41
41
would not happen if a custom resource is deleted.
42
42
43
+
To use finalizers the reconciler have to implement [`Cleaner<P>`](https://github.com/java-operator-sdk/java-operator-sdk/blob/b82c1f106968cb3eb18835c5e9cd1e4d5c40362e/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/Cleaner.java) interface.
44
+
In other words, finalizer is added if the `Reconciler` implements `Cleaner` interface. If not, no
45
+
finalizer is added and/or removed.
46
+
43
47
Finalizers are automatically added by the framework as the first step, thus after a custom resource is created, but
44
48
before the first reconciliation. The finalizer is added via a separate Kubernetes API call. As a result of this update,
45
49
the finalizer will be present. The subsequent event will be received, which will trigger the first reconciliation.
@@ -50,7 +54,6 @@ in some specific corner cases, when there would be a long waiting period for som
50
54
51
55
The name of the finalizers can be specified, in case it is not, a name will be generated.
52
56
53
-
Automatic finalizer handling can be turned off, so when configured no finalizer will be added or removed.
54
57
See [`@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)
55
58
annotation for more details.
56
59
@@ -66,7 +69,7 @@ When automatic finalizer handling is turned off, the `Reconciler.cleanup(...)` m
66
69
case when a delete event received. So it does not make sense to implement this method and turn off finalizer at the same
67
70
time.
68
71
69
-
## The `reconcile` and `cleanup` Methods of[`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)
72
+
## The `reconcile` and [`cleanup`](https://github.com/java-operator-sdk/java-operator-sdk/blob/b82c1f106968cb3eb18835c5e9cd1e4d5c40362e/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/Cleaner.java) Methods on 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)
70
73
71
74
The lifecycle of a custom resource can be clearly separated into two phases from the perspective of an operator. When a
72
75
custom resource is created or update, or on the other hand when the custom resource is deleted - or rather marked for
@@ -75,9 +78,8 @@ deletion in case a finalizer is used.
75
78
This separation-related logic is automatically handled by the framework. The framework will always call `reconcile`
76
79
method, unless the custom resource is
77
80
[marked from deletion](https://kubernetes.io/docs/concepts/overview/working-with-objects/finalizers/#how-finalizers-work)
78
-
. From the point when the custom resource is marked from deletion, only the `cleanup` method is called.
79
-
80
-
If there is **no finalizer** in place (see Finalizer Support section), the `cleanup` method is **not called**.
81
+
. From the point when the custom resource is marked from deletion, only the `cleanup` method is called, of course
82
+
only if the reconciler implements the `Cleaner` interface.
81
83
82
84
### Using [`UpdateControl`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/UpdateControl.java) and [`DeleteControl`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/DeleteControl.java)
0 commit comments