-
Notifications
You must be signed in to change notification settings - Fork 102
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
Run a cleanup plan when deleting instances #1108
Conversation
If an operator provides a 'cleanup' plan, this plan is run when the operator's instance is deleted from the cluster. This is achieved by detecting an instance deletion in the controller and adding a finalizer. If there is another plan currently in progress, this will be superseded by the cleanup plan. This allows the deletion of instances where a plan fails to complete.
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.
I would like to keep the controller code as compact as possible since it's the most important loop we have and isolate all the logic into the helper methods :) But other than that looking good!
Also there's one more case I need to think about to be sure we don't get stuck there :)
- we have finalizer on instance
- someone deletes the instance
- we run cleanup plan
- we store status with the finished plan execution
- request to remove the finalizer fails and we retry the reconcile
- now we don't re-run cleanup because it was already run but nothing is preventing e.g. other plan to be run here? https://github.com/kudobuilder/kudo/pull/1108/files#diff-45e4638e2c718ccd5d08635baec770b1R179
I am basically just trying to think if there's a way that we can remain stuck with the finalizer in, which is the most frustrating thing :) but I think we might be fine :)
test/e2e/cli-install-uninstall/03-check-events-for-cleanup.yaml
Outdated
Show resolved
Hide resolved
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.
One more thing :)
Thanks for the detailed case that isn't covered yet by the code. I'll change the logic to look like this:
|
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.
Okay, I am just at the edge of approving 😛 sorry. I would just like to minimize the update requests from 2 to 1 since I think that's possible. The rest is just nits :)
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.
Thanks, nice job! Don't forget about docs, please :)
Looks good to me. One thing I was thinking about was changes in operators:
|
@ANeumann82 Yes, the finalizer will be added automatically. But with the current code it won't get removed automatically. That's a good catch and is easy to fix, I'll add a fix. |
My greatest concern here isn't with this code (which lgtm!). |
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.
LGTM
@kensipe 💯, this needs to be clear from the documentation (that I'll work on today). Also, operator devs should expect that the |
What this PR does / why we need it:
If an operator provides a
cleanup
plan, this plan is run when the operator's instance is deleted from the cluster. This is achieved by detecting an instance deletion in the controller and adding a finalizer. If there is another plan currently in progress, this will be superseded by the cleanup plan. This allows the deletion of instances where a plan fails to complete.Fixes #1046