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/documentation/workflows.md
+28-24Lines changed: 28 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -40,14 +40,14 @@ Similarly to dependent resources, there are two ways to define workflows, in man
40
40
41
41
### Managed
42
42
43
-
Annotation can be used to declaratively define a workflow for the reconciler. In this case the workflow is executed
43
+
Annotations can be used to declaratively define a workflow for the reconciler. In this case the workflow is executed
44
44
before the `reconcile` method is called. The result of the reconciliation is accessed through the `context` object.
45
45
46
-
Following sample shows a hypothetical sample, where there are two resources a Deployment and a ConfigMap, where
47
-
the ConfigMap depends on the deployment. Deployment has a ready condition so, the config map is only reconciled after
48
-
the Deployment and only if that is ready (see readypostcondition). The ConfigMap reconcile precondition, there
49
-
only reconciled if that condition holds. In addition to that contains a deletepostCondition, do only considered to be
50
-
deleted if that condition holds.
46
+
Following sample shows a hypothetical sample to showcase all the elements, where there are two resources a Deployment and
47
+
a ConfigMap, where the ConfigMap depends on the deployment. Deployment has a ready condition so, the config map is only
48
+
reconciled after the Deployment and only if it is ready (see ready-postcondition). The ConfigMap has attached reconcile
49
+
precondition, therefore it is only reconciled if that condition holds. In addition to that has a delete-postCondition,
50
+
thus only considered to be deleted if that condition holds.
51
51
52
52
```java
53
53
@ControllerConfiguration(dependents= {
@@ -144,7 +144,7 @@ public class WebPageDependentsWorkflowReconciler
144
144
## Workflow Execution
145
145
146
146
This section describes how a workflow is executed in details, how is the ordering determined and how condition and
147
-
errors effect behavior. The workflow execution as also its API denotes, can be divided to into two parts,
147
+
errors affect the behavior. The workflow execution as also its API denotes, can be divided to into two parts,
148
148
the reconciliation and cleanup. [Cleanup](https://javaoperatorsdk.io/docs/features#the-reconcile-and-cleanup) is
149
149
executed if a resource is marked for deletion.
150
150
@@ -153,8 +153,8 @@ executed if a resource is marked for deletion.
153
153
154
154
-**As complete as possible execution** - when a workflow is reconciled, it tries to reconcile as many resources as
155
155
possible. Thus is an error happens or a ready condition is not met for a resources, all the other independent resources
156
-
will be still reconciled. So this is exactly the opposite of fail-fast approach. The assumption is that in this way
157
-
the overall desired state is achieved faster than with a fail fast approach.
156
+
will be still reconciled. This is the opposite to fail-fast approach. The assumption is that eventually in this way the
157
+
overall desired state is achieved faster than with a fail fast approach.
158
158
-**Concurrent reconciliation of independent resources** - the resources which are not dependent on each are processed
159
159
concurrently. The level of concurrency is customizable, could be set to one if required. By default, workflows use
160
160
the executor service from [ConfigurationService](https://github.com/java-operator-sdk/java-operator-sdk/blob/6f2a252952d3a91f6b0c3c38e5e6cc28f7c0f7b3/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ConfigurationService.java#L120-L120)
@@ -166,17 +166,17 @@ This section describes how a workflow is executed, first the rules are defined,
166
166
### Rules
167
167
168
168
1. DR is reconciled if it does not depend on another DR, or ALL the DRs it depends on are ready. In case it
169
-
has a reconcile-precondition that must be met too. (So her ready means that it is successfully reconciled - without
170
-
any error - and if it has a ready condition that is met).
169
+
has a reconcile-precondition that condition must be met too. (So here ready means that it is successfully
170
+
reconciled - without any error - and if it has a ready condition that condition is met).
171
171
2. If a reconcile-precondition of a DR is not met, it is deleted. If there are dependent resources which depends on it
172
-
are deleted first too - this applies recursively. That means that DRs are always deleted in revers order compared
172
+
are deleted too as first - this applies recursively. That means that DRs are always deleted in revers order compared
173
173
how are reconciled.
174
-
3. Delete is called on a dependent resource if as described in point 2. it (possibly transitively) depends on A DR which
175
-
did not meet it's reconcile condition, and has not DRs depends on it, or if the DR-s which depends on it are
176
-
successfully deleted. "Delete is called" means, that the dependent resource is checked if it implements `Deleter` interface,
177
-
if implements it but do not implement `GarbageCollected` interface, the `Deleter.delete` method called. If a DR
178
-
does not implement `Deleter` interface, it is considered as deleted automatically. Successfully deleted means,
179
-
that it is deleted and if a delete-postcondition is present it is met.
174
+
3. Delete is called on a dependent resource if as described in point 2. it (possibly transitively) depends on a DR which
175
+
did not meet it's reconcile condition, and has no DRs depends on it, or if the DR-s which depends on it are already
176
+
successfully deleted (within actual execution). "Delete is called" means, that the dependent resource is checked
177
+
if it implements `Deleter` interface, if implements it but do not implement `GarbageCollected` interface,
178
+
the `Deleter.delete` method called. If a DR does not implement `Deleter` interface, it is considered as deleted
179
+
automatically. Successfully deleted means, that it is deleted and if a delete-postcondition is present it is met.
180
180
181
181
### Samples
182
182
@@ -196,7 +196,7 @@ stateDiagram-v2
196
196
</div>
197
197
198
198
- At the workflow the reconciliation of the nodes would happen in the following way. DR with index `1` is reconciled.
199
-
After DR `2` and `3` is reconciled concurrently, if both finished reconciling, node `4` is reconciled.
199
+
After that DR `2` and `3` is reconciled concurrently, if both finished their reconciliation, node `4` is reconciled too.
200
200
- In case for example `2` would have a ready condition, that would be evaluated as "not met", `4` would not be reconciled.
201
201
However `1`,`2` and `3` would be reconciled.
202
202
- In case `1` would have a ready condition that is not met, neither `2`,`3` or `4` would be reconciled.
@@ -230,10 +230,10 @@ the whole workflow.
230
230
The rule is relatively simple:
231
231
232
232
Delete is called on a DR if there is no DR that depends on it, or if the DR-s which depends on it are
233
-
successfully already deleted. Successfully deleted means, that it is deleted and if a delete-postcondition is present
234
-
it is met. "Delete is called" means, that the dependent resource is checked if it implements `Deleter` interface,
235
-
if implements it but do not implement `GarbageCollected` interface, the `Deleter.delete` method called. If a DR
236
-
does not implement `Deleter` interface, it is considered as deleted automatically.
233
+
already deleted successfully (withing this execution of workflow). Successfully deleted means, that it is deleted and
234
+
if a delete-postcondition is present it is met. "Delete is called" means, that the dependent resource is checked if it
235
+
implements `Deleter` interface, if implements it but do not implement `GarbageCollected` interface, the `Deleter.delete`
236
+
method called. If a DR does not implement `Deleter` interface, it is considered as deleted automatically.
237
237
238
238
### Sample
239
239
@@ -263,7 +263,11 @@ that will contain all the related exceptions.
263
263
The exceptions can be handled by [`ErrorStatusHandler`](https://github.com/java-operator-sdk/java-operator-sdk/blob/86e5121d56ed4ecb3644f2bc8327166f4f7add72/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/AggregatedOperatorException.java)
264
264
265
265
## Notes and Caveats
266
-
266
+
267
+
- Delete is almost always called on every resource during the cleanup. However, it might be the case that the resources
268
+
was already deleted in a previous run, or not even created. This should not be a problem, since dependent resources
269
+
usually cache the state of the resource, so are already aware that the resource not exists, thus basically doing nothing
270
+
if delete is called on an already not existing resource.
267
271
- If a resource has owner references, it will be automatically deleted by Kubernetes garbage collector if
268
272
the owner resource is marked for deletion. This might not be desirable, to make sure that delete is handled by the
269
273
workflow don't use garbage collected kubernetes dependent resource, use for example [`CRUDNoGCKubernetesDependentResource`](https://github.com/java-operator-sdk/java-operator-sdk/blob/86e5121d56ed4ecb3644f2bc8327166f4f7add72/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/kubernetes/CRUDNoGCKubernetesDependentResource.java).
0 commit comments