-
Notifications
You must be signed in to change notification settings - Fork 2
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
EVEREST-496 Multi namespace support #169
Conversation
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.
In general the idea with targetNamespaces
for the allowed list and status.namespaces
for the actual list looks good, however to keep the lists consistent we would need to handle the deletion of
- the targetNamespaces
- the actual namespaces in the cluster
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.
The implementation itself looks good, my concerns are resolved. Approving the PR to unblock it in case the massive "Cons" section is considered by the product as the limitations we can live with.
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.
Overall the PR looks like it is functionally correct however, I think the followed approach is overly complex.
I argue that we don't need the BackupStorage controller at all. We already have an index and watcher configured in the DBC controller that runs the reconciliation loop every time a secret referenced by a BS triggers an event.
Therefore, we can use this same mechanism to create or update the end secret without needing to keep track of any namespace. In a sense we can think of this secret as being linked to a specific DBC than to the generic BS.
Moreover, we already use this approach for PG because the secret format needs to be different than the one specified in the BS which is the same for PXC/PSMDB. See here and here
Well, this was my first approach to solving the issue. This works fine for the backupStorages or monitoringConfigs in the single namespace scenario. Since the idea is to create backupstorages or monitoring configs in the default namespace (percona-everest) the existence of the objects is only in the default namespace. However, databasecluster controller replicates secrets across namespaces (since they are namespaced) there's no way (at least I know) to bind that secret with the backupStorage or monitoringConfig. Since the logic for backup storage and monitoring config is the same I'll describe the flow based on backup storage Let's take a look at the backup storage In the default namespace. To ensure that the secret will be deleted we can use ownerreferences here and we don't quite need a controller here. The backend or some other controller can create it for you yet, once the backupstorage is deleted, the secret will be deleted as well. Since secrets are namespaced to enable the multi namespace support in the cluster-wide mode we need to replicate them to the targetNamespace during the reconciliation of database clusters(because this is the only place when we need to ensure that the secret exists). We can't use ownerreferences here because they are not designed for that and we need to come up with a way to store the information where the secret was created. Here are the labels to link the secret in the different namespace with the existing backup storage. After testing this using indexers and watchers, when the user tries to delete the secret from a different namespace the reconciliation loop does not start because there's no event generated/passed to the operator after the deletion and it ends in the inconsistent state. Hence, we need to have an additional controller to ensure that after backup storage deletion, all secrets across all namespaces will be created and here we have finalizers as an additional handle to block the deletion. We need to delete all secrets across all namespaces except the default one (because we use owner references here and the deletion might block here because of cross-linking between entities) Since the backupstorage controller is namespaced (because we create backup storages only in the default namespace) we need to have a way to watch for secrets and run reconciliation of the backup storage entity on the secret change. For the default secret in the default namespace we have I hope that it explains the solution after a couple of days of trying to implement as simply as I can. |
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.
This is such an important change that we can't merge it without proper tests for it.
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.
While reviewing I found a couple of tiny code style improvements, these are just some nitpicks so feel free to ignore them.
Co-authored-by: Diogo Recharte <[email protected]>
Co-authored-by: Diogo Recharte <[email protected]>
Co-authored-by: Diogo Recharte <[email protected]>
Co-authored-by: Diogo Recharte <[email protected]>
This reverts commit 56c2fbf.
This reverts commit acfd53e.
This reverts commit c1540d9.
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.
Thank you for adding the tests 🤗.
I think that the only important case we're missing would be to validate the TargetNamespaces feature works as intended but that's part of the error cases which we aren't testing anywhere so I can't say this is mandatory for now.
CHANGE DESCRIPTION
Problem:
EVEREST-496
That's a small PoC for cluster-wide operators that stores backup storage (the same applies for monitoring configs) in the percona-everest and replicates secrets across namespaces that it manages.
Pros:
Cons:
percona-everest
namespace for two components: BE and operatorYet we have an additional request for the cluster-wide operator to use admission webhooks to move validation logic from the BE side to the operator, however, the scope of change is huge because
CHECKLIST
Jira
Tests