Address Redis Cluster mode review follow-ups for #5153#5210
Open
Address Redis Cluster mode review follow-ups for #5153#5210
Conversation
Three small follow-ups from the PR #5153 review that were deferred so the core cluster-mode support could land: - Document the cluster slot invariant for storeUpstreamTokensScript. The script reads oldUserID from KEYS[1] inside its body to keep the user-set bookkeeping atomic, so the user-set keys are constructed dynamically from ARGV[4] rather than declared as KEYS. The new comment makes the {ns:name} hash-tag requirement explicit, so a future refactor that rebuilds the prefix without the tag will be caught in review rather than silently regressing on standalone Redis and exploding with CROSSSLOT on a real cluster. - Filter SMEMBERS results in GetAllUpstreamTokens, DeleteUpstreamTokens, and GetLatestUpstreamTokensForUser to entries that share the storage instance's keyPrefix, warn-logging anything dropped. A stray un-prefixed member (legacy data, an external admin op, a test fixture) would today surface as CROSSSLOT under cluster while passing on standalone; this turns it into a logged warning. The defensive filter is a pure helper with table-driven tests, plus a behavior test that captures slog output to prove the wiring at all three call sites. - Align the operator CRD `tls` doc with the storage-layer comment so that crd-api.md and `kubectl explain` both describe TLS as applying to "Redis/Valkey master or cluster nodes" — previously cluster-mode users reading the CRD field would not realise this same field configured TLS for cluster-node connections. Regenerated CRD YAML, Helm templates, and crd-api.md to match. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5210 +/- ##
==========================================
+ Coverage 67.78% 67.80% +0.01%
==========================================
Files 608 608
Lines 62212 62230 +18
==========================================
+ Hits 42172 42195 +23
+ Misses 16866 16862 -4
+ Partials 3174 3173 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Three small follow-ups from the PR #5153 review that were deferred so the core cluster-mode support could land. None change runtime behaviour beyond the defensive filter in #2 (which only triggers on stray index members).
storeUpstreamTokensScript(pkg/authserver/storage/redis.go). The script readsoldUserIDfromKEYS[1]inside its body to keep the user-set bookkeeping atomic, so the user-set keys are constructed dynamically fromARGV[4]rather than declared as KEYS. The new comment makes the{ns:name}hash-tag requirement explicit, so a future refactor that rebuilds the prefix without the tag will be caught in review rather than silently regressing on standalone Redis and exploding withCROSSSLOTon a real cluster. (Reviewer offered two options — KEYS[3]/KEYS[4] or this comment; the KEYS approach would require resolvingoldUserSetKeyoutside the script, which would break the atomic GET-of-old-userID the script exists to provide.)GetAllUpstreamTokens,DeleteUpstreamTokens, andGetLatestUpstreamTokensForUserto entries that share the storage instance'skeyPrefix, warn-logging anything dropped. A stray un-prefixed member (legacy data, an external admin op, a test fixture) would today surface asCROSSSLOTunder cluster while passing on standalone; this turns it into a logged warning. The defensive filter is a pure helper with table-driven tests, plus a behaviour test that capturesslogoutput to prove the wiring at all three call sites.tlsdoc with the storage-layer comment so thatcrd-api.mdandkubectl explainboth describe TLS as applying to "Redis/Valkey master or cluster nodes" — previously cluster-mode users reading the CRD field would not realise this same field configured TLS for cluster-node connections. Regenerated CRD YAML, Helm templates, andcrd-api.mdto match.Refs #5153.
Type of change
Test plan
task test)task lint-fix)New unit tests:
TestFilterIndexMembersByPrefix— pure helper, table-driven (parallel).TestForeignMembersFilteredFromIndexOps— non-parallel, capturesslogdefault and asserts each of the three operations emits a warn naming the operation, dropped member, and expected prefix.API Compatibility
v1beta1API.The CRD field
RedisStorageConfig.TLSitself is unchanged — only the godoc string is updated. Generated CRD YAML differs only in thedescription:field of the same property.Changes
pkg/authserver/storage/redis.gofilterIndexMembersByPrefix+warnDroppedIndexMembershelpers; wire intoGetAllUpstreamTokens,DeleteUpstreamTokens,GetLatestUpstreamTokensForUser; document cluster slot invariant onstoreUpstreamTokensScriptpkg/authserver/storage/redis_test.gocmd/thv-operator/api/v1beta1/mcpexternalauthconfig_types.goTLSfield doc to "master or cluster nodes"crd-api.mdDoes this introduce a user-facing change?
Operators will see the updated TLS field description in
kubectl explainand the published CRD reference. The defensiveSMEMBERSfilter is silent on a healthy keyspace; it only surfaces aWARNlog if an index set somehow contains a foreign-prefix entry.Generated with Claude Code