adoption: use per-role label keys and indexes to fix multi-secret conflicts#417
Merged
Conversation
…flicts
When a SpiceDBCluster references the same secret for multiple
credential roles, the previous single-index / single-label approach caused
adoption handlers to treat each other's secrets as stale and remove labels.
Each credential role now gets its own label key
(authzed.com/credential-type-{role}) and its own cache index, so handlers
only see secrets that carry their specific label. A shared secret carries
all applicable role labels simultaneously, appearing in every relevant index.
Role-qualified SSA field managers (spicedb-operator-{role}) prevent the
second apply from releasing ownership of the first role's label.
tstirrat15
approved these changes
May 4, 2026
Contributor
tstirrat15
left a comment
There was a problem hiding this comment.
Generally makes sense
Comment on lines
+114
to
+119
| case CredentialTypeDatastoreURI: | ||
| return CredentialTypeDatastoreURILabelKey | ||
| case CredentialTypePresharedKey: | ||
| return CredentialTypePresharedKeyLabelKey | ||
| case CredentialTypeMigrationSecrets: | ||
| return CredentialTypeMigrationSecretsLabelKey |
Contributor
There was a problem hiding this comment.
Worth making static maps out of these?
Contributor
Author
There was a problem hiding this comment.
I think in this case I prefer the switch just for the simpler defaulting. But no strong opinion.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Description
When a SpiceDBCluster references the same secret for multiple credential roles, the previous single-index / single-label approach caused adoption handlers to treat each other's secrets as stale and remove labels.
Each credential role now gets its own label key
(authzed.com/credential-type-{role}) and its own cache index, so handlers only see secrets that carry their specific label. A shared secret carries all applicable role labels simultaneously, appearing in every relevant index.
Role-qualified SSA field managers (spicedb-operator-{role}) prevent the second apply from releasing ownership of the first role's label.
Testing
See tests
References
Fixes #409