-
-
Notifications
You must be signed in to change notification settings - Fork 324
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
Finalizer helper #291
Comments
Resources from Lars' code: https://github.com/stackabletech/operator-rs/blob/main/src/finalizer.rs |
You're welcome to use any of our code. |
From what I understand, unless The function in my head would look like this:
Which should be fairly easy to implement, as it just injects a bit of logic before This is the same as how "child resources" are handled currently. (unless I'm missing something?) Which requires user to manually ensure resources created during
I'm not sure this is possible/desired, since most likely you'll need external state to realize whether the clean up is finished or not. Unless you just mean from the k8s resource's point of view, in that case it should be trivial to just avoid calling the user-provided closure when the corresponding finalizer does not exist anymore. |
We could provide a async fn finalizable<K, ApplyFut, CleanupFut>(api: &Api<K>, finalizer: &str, obj: K, apply: impl Fn(K) -> impl ApplyFut, cleanup: Fn(K) -> impl CleanupFut) -> Result<ReconcilerResult> {
if obj.meta().finalizers.contains(finalizer) {
if obj.meta().deletion_timestamp == None {
apply(obj).await
} else {
let res = cleanup(obj).await?;
// .. remove finalizer
Ok(res)
}
} else {
if obj.meta().deletion_timestamp == None {
// add finalizer
}
Ok(ReconcilerResult { requeue_at: None })
}
} I could see eventually baking that into |
Should:
See #290 for motivation. Make sure to mention in
Controller
's documentation.The text was updated successfully, but these errors were encountered: