-
Notifications
You must be signed in to change notification settings - Fork 593
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
[chore] finalizer removal & teardown logic cleanup #1522
Conversation
Codecov Report
@@ Coverage Diff @@
## next #1522 +/- ##
==========================================
- Coverage 51.44% 50.31% -1.13%
==========================================
Files 91 91
Lines 6316 6423 +107
==========================================
- Hits 3249 3232 -17
- Misses 2773 2884 +111
- Partials 294 307 +13
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
efe4b84
to
0d14ba4
Compare
flagging as do not merge because before we merge this I want to do some rebasing. |
tl;dr
The commits not directly related to the finalizer stuff look fine, but I have many questions about the finalizers. Do we know why this was a problem for Secrets specifically? While this does remove our finalizer from them, it remains on other resources (e.g. Ingresses), and I'd expect that those also block namespace deletion if not removed--AFAIK the problem is that K8S won't allow deletion of namespaces without deleting its contents, and while it cascades these deletes automatically, the cascaded deletes won't finish until all finalizers are cleared from those objects. The original section of the reconciler code in the current tip of next did add our finalizer to everything, but it also apparently removed it from everything being deleted. Was there some reason that Secrets failed timestamp condition there, or consistently resulted in an error when we called That all said, this and the error Jimin encountered (which is caused by me not properly adding permissions in #1457) makes me question whether we need the finalizers at all. The kubebuilder example includes some logic we don't have to confirm the presence of the finalizer before doing things:
but we don't: we simply delete all deleting resources from our cache before stripping the finalizer, without any check to see if the finalizer is present. We still do that in the proposed version, though with additional logic to requeue. We won't remove our finalizer on resources that still include it until the proxy delete actually succeeds (because the requeue return precedes the finalizer clear), but we'll requeue indefinitely until the proxy delete does in fact succeed whether or not the finalizer is set. The class annotation distinction between resources that get finalizers and those that don't seems rather arbitrary, as anything we reconcile influences Kong proxy configuration. For example, Ingresses (which need class annotations and will get a finalizer) result in routes, whereas KongPlugins attached to a Service (which do not need class annotations and will not get a finalizer) result in a plugin on a Kong service. It's not clear why we'd block resource deletion on one but not the other. Kubernetes guidance on when and why to use finalizers is unfortunately rather unclear, but my rough takeaway is that you use them when:
For us:
In general, the UX for finalizers also seems poor:
|
This was happening due to a race condition: the tests weren't verifying that their namespaces were properly torn down, so the controller would be shut down before it could process all finalizers. This is now fixed with the namespace teardown code.
I totally feel you on this. Long story short? When this was originally written the intention was to ensure the relevant configurations in the proxy were actually removed before letting the objects delete. Technical limitations regarding our integration with the Kong Admin API make this really hard to pull off right now so this didn't actually get implemented as originally intended. So ultimately given the feasibility issues to make good use of them, I'll pull them all out, we can add them back later if we find solid use cases to do so. 👍 |
These were requested changes in a previous code review which I accidentally left in my git stash, so just getting them committed now so they are in.
Originally we added finalizers with the intention of holding back object deletion until we were certain that we had removed the relevant configuration from the Kong Admin API. Ultimately at the time of writing it's not feasible to get this done, so this removes a half of the implementation which was causing us complexity without any added value.
f76ff39
to
1553b0f
Compare
@rainest I'm totally with you on finalizers. Originally when they were added in the railgun prototype the intention was to ensure consistency: the contents that result from objects should be removed from the Kong Proxy state before removing relevant objects from Kubernetes. However, given some of the limitations that exist today, the desired consistency is not yet feasible. All that said, I'm in agreement with you, check 1553b0f and let me know what you think 👍 |
gonna get things working and then re-open 👍 |
Fixed and working locally now 👍 |
What this PR does / why we need it:
Which issue this PR fixes
fixes #1515