-
Notifications
You must be signed in to change notification settings - Fork 222
Separate interface for cleanup part of reconciler and Dependent Resources #1035
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 19 commits
c01b7d7
9dcfe42
21cc194
ff1aa95
14ec0d7
94b68da
6c33fa5
8416246
396b5a1
4831df7
7360e66
aa1a2b6
6f5dfb8
b12f728
bb1b135
49ef6c7
e41bf14
1443d1d
cf5c716
2563bae
3a68a09
da8424b
ae75dcf
6935c2e
4616838
09c20f9
a024bc3
e3dd811
6024cd0
de52b3c
606480e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package io.javaoperatorsdk.operator.api.reconciler; | ||
|
||
import io.fabric8.kubernetes.api.model.HasMetadata; | ||
|
||
public interface Cleaner<P extends HasMetadata> { | ||
|
||
/** | ||
* Note that this method turns on automatic finalizer usage. | ||
* | ||
* The implementation should delete the associated component(s). This method is called when an | ||
* object is marked for deletion. After it's executed the custom resource finalizer is | ||
* automatically removed by the framework; unless the return value is | ||
* {@link DeleteControl#noFinalizerRemoval()}, which indicates that the controller has determined | ||
* that the resource should not be deleted yet. This is usually a corner case, when a cleanup is | ||
* tried again eventually. | ||
* | ||
* <p> | ||
* It's important for implementations of this method to be idempotent, since it can be called | ||
* several times. | ||
* | ||
* @param resource the resource that is marked for deletion | ||
* @param context the context with which the operation is executed | ||
* @return {@link DeleteControl#defaultDelete()} - so the finalizer is automatically removed after | ||
* the call. {@link DeleteControl#noFinalizerRemoval()} if you don't want to remove the | ||
* finalizer to indicate that the resource should not be deleted after all, in which case | ||
* the controller should restore the resource's state appropriately. | ||
*/ | ||
DeleteControl cleanup(P resource, Context<P> context); | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package io.javaoperatorsdk.operator.api.reconciler.dependent; | ||
|
||
import io.fabric8.kubernetes.api.model.HasMetadata; | ||
import io.javaoperatorsdk.operator.api.reconciler.Context; | ||
|
||
/** | ||
* DependentResource can implement this interface to denote it requires explicit logic to clean up | ||
* resources. | ||
* | ||
* @param <P> primary resource type | ||
*/ | ||
@FunctionalInterface | ||
public interface Cleaner<P extends HasMetadata> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why didn't you keep the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 it will also help disambiguate import resolution due to the same class name. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will change it to Deleter, the reason was first, that Creator and Updater have a different role - those just exists in the context of |
||
void cleanup(P primary, Context<P> context); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this should also return a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How that would work with more Dependent Resources returning different Delete Controls? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. Ultimately, though, I think it will make sense for dependent resources to return more information so that the main reconciler can make decisions based on the returned status… There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, for now only the state is available, at that time. Although we changed the |
||
} |
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.