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
WithFinalizer #228
WithFinalizer #228
Conversation
WithFinalizer is a SubReconciler that allows external state to be allocated and then cleaned up once the parent resource is deleted. When the parent resource is not terminating, the finalizer is set on the parent resource before the nested reconciler is called. When the parent resource is terminating, the finalizer is cleared only after the nested reconciler returns without an error. Signed-off-by: Scott Andrews <andrewssc@vmware.com>
Codecov Report
@@ Coverage Diff @@
## main #228 +/- ##
==========================================
+ Coverage 65.07% 66.60% +1.52%
==========================================
Files 9 9
Lines 1008 1099 +91
==========================================
+ Hits 656 732 +76
- Misses 330 345 +15
Partials 22 22
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that finalizers can be tricky, I could imagine it to be helpful if there’re a few words of guidance when to choose WithFinalizer
over Sync/ChildReconciler
with Finalize
. I would find convenience or expressiveness or improved composability ensuring for the adopter.
Nice, @scothis!
@@ -342,6 +343,36 @@ func SwapRESTConfig(rc *rest.Config) *reconcilers.SubReconciler { | |||
} | |||
``` | |||
|
|||
#### WithFinalizer | |||
|
|||
[`WithFinalizer`](https://pkg.go.dev/github.com/vmware-labs/reconciler-runtime/reconcilers#WithFinalizer) allows external state to be allocated and then cleaned up once the parent resource is deleted. When the parent resource is not terminating, the finalizer is set on the parent resource before the nested reconciler is called. When the parent resource is terminating, the finalizer is cleared only after the nested reconciler returns without an error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[suggestion]: Can you motivate usage of a WithFinalizer
subreconciler over a ChildReconciler/SyncRenciler
with Finalize
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added a note under the finalizers section. We can continue to iterate on it
Signed-off-by: Scott Andrews <andrewssc@vmware.com>
WithFinalizer is a SubReconciler that allows external state to be
allocated and then cleaned up once the parent resource is deleted. When
the parent resource is not terminating, the finalizer is set on the
parent resource before the nested reconciler is called. When the parent
resource is terminating, the finalizer is cleared only after the nested
reconciler returns without an error.
Signed-off-by: Scott Andrews andrewssc@vmware.com