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

When CRDs are not upgraded, ReplicatedSecrets may copy infinitely #1295

Closed
Miles-Garnsey opened this issue Apr 22, 2024 · 6 comments · Fixed by #1296
Closed

When CRDs are not upgraded, ReplicatedSecrets may copy infinitely #1295

Miles-Garnsey opened this issue Apr 22, 2024 · 6 comments · Fixed by #1296
Labels
done Issues in the state 'done' enhancement New feature or request

Comments

@Miles-Garnsey
Copy link
Member

Miles-Garnsey commented Apr 22, 2024

What is missing?

We now use the DropLabels field in the replicatedSecret to ensure that a prefixed secret copied into the same namespace as it's original (and the ReplicatedSecret controlling the replication) does not continue to replicate infinitely.

But if a CRD is not properly upgraded so the DropLabels field exists, or if a user accidentally misconfigures a ReplicatedSecret, then infinite replication can still occur. We should put a safeguard in place to ensure that a secret replicating into it's own namespace will never replicate if doing so would cause an infinite loop.

It is worth noting that we cannot assure this in the case that a ReplicationTarget has been defined with a non zero K8sContext which nonetheless points back to the local cluster. In this case, there is no way for us to tell that the K8sContext is the local one, and infinite replication might still occur.

Why do we need it?

We've seen this bug happen once before and it might be dangerous to the cluster given that it continues to create so many copies. It should not happen in ordinary operations, but the extra safety is justified.

Environment

  • K8ssandra Operator version:

    Insert image tag or Git SHA here

Anything else we need to know?:

@Miles-Garnsey Miles-Garnsey added the enhancement New feature or request label Apr 22, 2024
@Miles-Garnsey Miles-Garnsey moved this to Ready For Review in K8ssandra Apr 22, 2024
@adejanovski adejanovski added the ready-for-review Issues in the state 'ready-for-review' label Apr 22, 2024
@burmanm
Copy link
Contributor

burmanm commented Apr 22, 2024

We can replicate the secret to its own destination, that's no problem. A copied secret should just have an annotation that indicates it's a copy and thus it would never be used as a source.

@adejanovski
Copy link
Contributor

the problem is that these secrets are replicated by another ReplicatedSecret, so we can't do what you describe.

@burmanm
Copy link
Contributor

burmanm commented Apr 22, 2024

We shouldn't have a case with Secret -> ReplicatedSecret -> Secret -> ReplicatedSecret -> Secret. Something's gone horrible wrong at that point and it's good that it fails.

@adejanovski
Copy link
Contributor

Let's see if we can get away with a single ReplicatedSecret. Not sure the cluster label system will allow this, but worth a shot.

@Miles-Garnsey
Copy link
Member Author

Let's see if we can get away with a single ReplicatedSecret. Not sure the cluster label system will allow this, but worth a shot.

I can't see any way to do this given that you want to replicate from MedusaConfig namespace -> K8ssandraCluster namespace -> DC namespace.

This functionality will go away once we finally remove the ability to have the MedusaConfig in a different namespace to the K8ssandraCluster, but as long as we maintain support for that functionality, we probably want to merge this to cover off a somewhat dangerous bug which I suspect can hit cluster performance pretty bad.

@Miles-Garnsey
Copy link
Member Author

I guess the alternative here is to do something like add an annotation to the replica secret which notes which ReplicatedSecret created it (or use the OwnerReference). We could then filter out any secret which had been replicated once while still allowing these multi-hop replicas.

Let me know if you'd prefer that approach.

@github-project-automation github-project-automation bot moved this from Ready For Review to Done in K8ssandra May 1, 2024
@adejanovski adejanovski added done Issues in the state 'done' and removed ready-for-review Issues in the state 'ready-for-review' labels May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
done Issues in the state 'done' enhancement New feature or request
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants