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

[Story] Operator should handle target namespace deletion #941

Closed
Tracked by #784
ebaron opened this issue Sep 10, 2024 · 4 comments · Fixed by #950
Closed
Tracked by #784

[Story] Operator should handle target namespace deletion #941

ebaron opened this issue Sep 10, 2024 · 4 comments · Fixed by #950
Assignees
Labels
bug Something isn't working

Comments

@ebaron
Copy link
Member

ebaron commented Sep 10, 2024

I guess for this to work the Operator would also need to be watching for any namespaces to be created/deleted in the cluster, so that it can reconcile by deleting the original secrets if namespaces are deleted, or recreating/re-copying them if a matching namespace is recreated too?

I suppose other objects that are placed in target namespaces would suffer from the same issue (e.g. role bindings, CA secrets). This might be a bit tricky to handle. Since we can't have cross-namespace owner references, maybe we could do something like this:

  1. Apply a label to all cross-namespace objects pointing to the namespace/name of the CR
  2. Add a custom controller watch on cross-namepsace object types (e.g. secret, rolebinding) that checks for the label(s)
  3. If the label exists, enqueue a reconcile request for that CR's namespace/name
  4. Controller recreates any missing objects

As for deleting the certificate object from the install namespace for deleted namespaces, we could issue a get request for the namespace and, if it doesn't exist, delete the certificate and secret. I think the namespace deletion event should be captured with the above custom controller watch.

Originally posted by @ebaron in #938 (comment)

@ebaron ebaron self-assigned this Sep 10, 2024
@ebaron ebaron added the bug Something isn't working label Sep 10, 2024
@ebaron
Copy link
Member Author

ebaron commented Sep 10, 2024

@andrewazores I suppose with the above implementation, that CR would fail to reconcile until the namespace is recreated. The operator would keep trying to create the objects in a non-existent namespace. Perhaps that's okay, the CR does specify an invalid spec if the target namespace doesn't exist (currently).

@andrewazores
Copy link
Member

Perhaps that's okay, the CR does specify an invalid spec if the target namespace doesn't exist (currently).

I think that makes enough sense - we just have to make sure we document this. But I agree that listing target namespaces that don't exist should be considered an invalid spec, and it's probably best that this results in some kind of a failure rather than a silent acceptance. In particular, if we are doing things like copying secrets into the target namespaces, then silently failing if the namespace doesn't exist, only to then perform the copy at a later date if it does get created, seems like it might be surprising behaviour and potentially a security issue - the user might have typo'd a namespace name by accident, not noticed because the deployment succeeded, and then their secret gets inadvertently created and shared into a different namespace later on which they did not intend.

We have talked about this kind of problem before, where the Operator should be proactive about checking RBAC for each of the target namespaces - is there a particular Issue we can link this to?

@ebaron
Copy link
Member Author

ebaron commented Sep 10, 2024

We have talked about this kind of problem before, where the Operator should be proactive about checking RBAC for each of the target namespaces - is there a particular Issue we can link this to?

Do you mean this sort of multi-tenancy issue: #579?

@andrewazores
Copy link
Member

Yes that looks like it's probably what I'm thinking of.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants