-
Notifications
You must be signed in to change notification settings - Fork 95
Prevent blocking namespace deletion #299
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
Conversation
e87f0b1 to
595caf4
Compare
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.
Question: rather than adding a new watch+cache on namespaces, would it be easier to handle the unable to create new content in namespace NS because it is being terminated error when applying the job? You can use apierrors.IsForbidden(err) && apierrors.HasStatusCause(err, corev1.NamespaceTerminatingCause) for this.
|
@brandond Thank you for the feedback! Inspecting the error was my first approach actually. Sadly it's an |
|
You would need to do a type switch to see if the return is merr.Errors (type alias for []error) or just a single error - but I think that's preferable if it works. While it may be a little more code, the alternative is adding a namespace cache, or doing an uncached lookup against the apiserver every time this OnRemove handler runs - which may be multiple times in short succession due to how wrangler retries handlers. |
Signed-off-by: Martin Richter <[email protected]>
595caf4 to
f6f8fbc
Compare
|
Replaced the commit with the discussed solution |
|
LGTM - but does it work? Can you add a test for this to https://github.com/k3s-io/helm-controller/blob/master/test/suite/helm_test.go ? Should be pretty easy to just copy one of the existing create/delete tests - just add a step in the middle to delete the ns. |
|
Only checked the make file and didn't see the e2e tests in scripts, thanks for your hint. Added test coverage. FYI I had to change the controller args to start cluster scoped for this to be possible. |
|
LGTM, tests look good - but please make sure all your commits have --sign-off for DCO. |
…get namespace Signed-off-by: Martin Richter <[email protected]>
b68e62e to
009255c
Compare
|
Sorry, my muscle memory favors |
Prevent blocking namespace deletion by yielding in chart handlers
OnRemovecallback if target namespace is in terminating phase.Fixes #135