Skip to content
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

Fix reconcile of deleted resources in namespaced mode #69

Conversation

roivaz
Copy link
Contributor

@roivaz roivaz commented Jun 2, 2021

There is a bug when using the locked resources controller where deleted resources are never reconciled. This occurs because the predicate for deletion events has code that checks if the Namespace of the deleted resource is in the process of being terminated. This only works when the reconciler is used with cluster scoped permissions. The current code returns false if an error occurs trying to retrieve the Namespace, which leads to the resources never being reconciled again. This could be not only a permissions problem, but also a temporary unavailability of the API server.

The proposed solution is to return true, as a fallback, if the get operation of the Namespace resource fails so the resource is reconciled. This is not even a problem in the case the Namespace is actually being deleted, as the api server will refuse to perform any create/update if the Namespace is being terminated.

The predicate function for Delete events of the lockedresources reconciler assumes the client is a cluster scoped client with permissions to Get Namespace resources. If the call to get a Namespace fails, the deleted resources will not be reconciled. This commit fixes that by trying to reconcile the deleted resource even if the call to get the Namespace fails. This causes no problems as the k8s API will deny any create/update operation in a Namespace that's marked for termination (which was the original intention of the failing code)
@raffaelespazzoli raffaelespazzoli merged commit 2eaf121 into redhat-cop:master Jun 2, 2021
@roivaz roivaz deleted the fix/deleted-resources-not-reconciled branch January 21, 2022 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants