fix: should resolve SubNamespace conflict when sub-namespace deleted #149
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
Our tenants use GitOps to provision sub-namespaces, and not
kubectl-accurate
. We run on OpenShift, and OpenShift has a feature allowing users in theself-provisioner
cluster role to create namespaces by issuing a ProjectRequest create request. We want to migrate to Accurate, but will still have to support the OpenShift mechanism for a long time.Problem (solved in this PR)
Recently we've had users pre-creating an OpenShift Project before provisioning the SubNamespace resource that is supposed to control the desired namespace. This will not work, making the subnamespace enter a conflicting state right after creation by the tenant GitOps. The user observes this problem by inspecting the SubNamespace status and other GitOps failures caused by missing RBAC in the target namespace.
The natural thing to do when this happens, is to delete the OpenShift
Project
resource currently controlling the (empty) target namespace. When the project is deleted, OpenShift will terminate the controlled namespace. So far, so good.Expected behavior: Accurate detects the namespace deletion and (re)creates the target namespace as sub-namespace, resolving the conflict state on the SubNamespace.
Actual behavior: Accurate eventually acts on the deleted namespace, resolving the conflict state, but this is not happening in a timely fashion. The exact time depends on the resync time initiated regularly by controller-runtime. But we have seen this take several hours, which is not acceptable.