Skip to content

Commit 68aadd6

Browse files
authored
Merge pull request operator-framework#373 from lburgazzoli/rc
Improve ResourceController
2 parents 2a01fdf + 63799a7 commit 68aadd6

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/ResourceController.java

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,32 @@ public interface ResourceController<R extends CustomResource> {
77

88
/**
99
* The implementation should delete the associated component(s). Note that this is method is
10-
* called when an object is marked for deletion. After its executed the custom resource finalizer
11-
* is automatically removed by the framework; unless the return value is false - note that this is
12-
* almost never the case. Its important to have the implementation also idempotent, in the current
13-
* implementation to cover all edge cases actually will be executed mostly twice.
10+
* called when an object is marked for deletion. After it's executed the custom resource finalizer
11+
* is automatically removed by the framework; unless the return value is {@link
12+
* DeleteControl#NO_FINALIZER_REMOVAL} - note that this is almost never the case. It's important
13+
* to have the implementation also idempotent, in the current implementation to cover all edge
14+
* cases actually will be executed mostly twice.
1415
*
1516
* @param resource
16-
* @return true - so the finalizer is automatically removed after the call. false if you don't
17-
* want to remove the finalizer. Note that this is ALMOST NEVER the case.
17+
* @return {@link DeleteControl#DEFAULT_DELETE} - so the finalizer is automatically removed after
18+
* the call. {@link DeleteControl#NO_FINALIZER_REMOVAL} if you don't want to remove the
19+
* finalizer. Note that this is ALMOST NEVER the case.
1820
*/
19-
DeleteControl deleteResource(R resource, Context<R> context);
21+
default DeleteControl deleteResource(R resource, Context<R> context) {
22+
return DeleteControl.DEFAULT_DELETE;
23+
}
2024

2125
/**
2226
* The implementation of this operation is required to be idempotent. Always use the UpdateControl
2327
* object to make updates on custom resource if possible. Also always use the custom resource
2428
* parameter (not the custom resource that might be in the events)
2529
*
26-
* @return The resource is updated in api server if the return value is present within Optional.
27-
* This the common use cases. However in cases, for example the operator is restarted, and we
28-
* don't want to have an update call to k8s api to be made unnecessarily, by returning an
29-
* empty Optional this update can be skipped. <b>However we will always call an update if
30-
* there is no finalizer on object and its not marked for deletion.</b>
30+
* @return The resource is updated in api server if the return value is not {@link
31+
* UpdateControl#noUpdate()}. This the common use cases. However in cases, for example the
32+
* operator is restarted, and we don't want to have an update call to k8s api to be made
33+
* unnecessarily, by returning {@link UpdateControl#noUpdate()} this update can be skipped.
34+
* <b>However we will always call an update if there is no finalizer on object and it's not
35+
* marked for deletion.</b>
3136
*/
3237
UpdateControl<R> createOrUpdateResource(R resource, Context<R> context);
3338

0 commit comments

Comments
 (0)