File tree 2 files changed +21
-4
lines changed
operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler
2 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ public interface Cleaner<P extends HasMetadata> {
6
6
7
7
/**
8
8
* This method turns on automatic finalizer usage.
9
- *
9
+ * <p>
10
10
* The implementation should delete the associated component(s). This method is called when an
11
11
* object is marked for deletion. After it's executed the custom resource finalizer is
12
12
* automatically removed by the framework; unless the return value is
@@ -21,9 +21,11 @@ public interface Cleaner<P extends HasMetadata> {
21
21
* @param resource the resource that is marked for deletion
22
22
* @param context the context with which the operation is executed
23
23
* @return {@link DeleteControl#defaultDelete()} - so the finalizer is automatically removed after
24
- * the call. {@link DeleteControl#noFinalizerRemoval()} if you don't want to remove the
25
- * finalizer to indicate that the resource should not be deleted after all, in which case
26
- * the controller should restore the resource's state appropriately.
24
+ * the call. Use {@link DeleteControl#noFinalizerRemoval()} when you don't want to remove
25
+ * the finalizer immediately but rather wait asynchronously until all secondary resources
26
+ * are deleted, thus allowing you to keep the primary resource around until you are sure
27
+ * that it can be safely deleted.
28
+ * @see DeleteControl#noFinalizerRemoval()
27
29
*/
28
30
DeleteControl cleanup (P resource , Context <P > context );
29
31
Original file line number Diff line number Diff line change @@ -8,10 +8,25 @@ private DeleteControl(boolean removeFinalizer) {
8
8
this .removeFinalizer = removeFinalizer ;
9
9
}
10
10
11
+ /**
12
+ * @return delete control that will remove finalizer.
13
+ */
11
14
public static DeleteControl defaultDelete () {
12
15
return new DeleteControl (true );
13
16
}
14
17
18
+ /**
19
+ * In some corner cases it might take some time for secondary resources to be cleaned up. In such
20
+ * situation, the reconciler shouldn't remove the finalizer until it is safe for the primary
21
+ * resource to be deleted (because, e.g., secondary resources being removed might need its
22
+ * information to proceed correctly). Using this method will instruct the reconciler to leave the
23
+ * finalizer in place, presumably to wait for a new reconciliation triggered by event sources on
24
+ * the secondary resources (e.g. when they are effectively deleted/cleaned-up) to check whether it
25
+ * is now safe to delete the primary resource and therefore, remove its finalizer by returning
26
+ * {@link #defaultDelete()} then.
27
+ *
28
+ * @return delete control that will not remove finalizer.
29
+ */
15
30
public static DeleteControl noFinalizerRemoval () {
16
31
return new DeleteControl (false );
17
32
}
You can’t perform that action at this time.
0 commit comments