fix: Batch CLUSTER ADDSLOTS for single-leader RedisCluster to avoid exec URL limit#1706
Open
svils wants to merge 7 commits intoOT-CONTAINER-KIT:mainfrom
Open
fix: Batch CLUSTER ADDSLOTS for single-leader RedisCluster to avoid exec URL limit#1706svils wants to merge 7 commits intoOT-CONTAINER-KIT:mainfrom
svils wants to merge 7 commits intoOT-CONTAINER-KIT:mainfrom
Conversation
33be324 to
9dac93a
Compare
…xec URL limit CreateSingleLeaderRedisCommand built a single redis-cli CLUSTER ADDSLOTS command with all 16384 slot numbers as arguments. This exceeds the Kubernetes pod exec SPDY URL length limit, causing the connection upgrade to fail and the cluster to stay stuck in Bootstrap forever. Replace with executeSingleLeaderAddSlots: - Redis 7+ (default): use CLUSTER ADDSLOTSRANGE 0 16383 — a single compact command that takes a start-end range pair - Redis <7 fallback: batch CLUSTER ADDSLOTS into chunks of 1000 per exec call to stay within the URL length limit Fixes OT-CONTAINER-KIT#1704 Signed-off-by: svils <63684363+svils@users.noreply.github.com>
9dac93a to
1d10833
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1706 +/- ##
=======================================
Coverage ? 29.88%
=======================================
Files ? 83
Lines ? 6743
Branches ? 0
=======================================
Hits ? 2015
Misses ? 4532
Partials ? 196 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…g infinite Failed state after pod restarts Broaden repairDisconnectedMasters to handle both failed masters and failed slaves (renamed to RepairDisconnectedNodes). For slaves, issue CLUSTER MEET to fix gossip and CLUSTER REPLICATE to re-establish replication so the follower resolves its master's current IP. Add RepairStaleReplication to detect connected followers whose master_link_status is down and re-issue CLUSTER REPLICATE. Harden cluster config defaults: - tcp-keepalive 60s (faster dead connection detection) - cluster-node-timeout 15000ms (more gossip recovery time, configurable) - cluster-allow-reads-when-down yes (unblock clients during repair) - probe TimeoutSeconds=5 / FailureThreshold=5 (prevent premature pod eviction) Fixes OT-CONTAINER-KIT#1692 Signed-off-by: svils <63684363+svils@users.noreply.github.com>
… is not empty" loop ExecuteRedisReplicationCommand uses `redis-cli --cluster add-node` to join followers to the cluster. This command requires the target node to be completely empty — no cluster state and no keys in database 0. After a leader-only CLUSTER RESET during single-node bootstrap (via executeFailoverCommand), the follower retains its previous cluster state and replicated data. The operator then enters an infinite error loop: [ERR] Node <cluster>-follower-0...is not empty. Either the node already knows other nodes (check with CLUSTER NODES) or contains some key in database 0. Add resetFollowerIfNotEmpty: before running add-node, check whether the follower knows other nodes or has keys in db0. If so, issue CLUSTER RESET HARD to clear both cluster state and data so add-node can succeed. The follower will re-sync from the master via full sync after joining. Related: OT-CONTAINER-KIT#1407 Signed-off-by: svils <63684363+svils@users.noreply.github.com>
…er-addslots-batch
7 tasks
…er-addslots-batch
6f7025e to
cbec96a
Compare
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
Fixes #1704
CreateSingleLeaderRedisCommandbuilt a singleredis-cli CLUSTER ADDSLOTS 0 1 2 ... 16383command with all 16384 slot numbers as individual arguments. When executed via the Kubernetes pod exec API (SPDY), the arguments are encoded as URL query parameters, exceeding the URL length limit. The connection upgrade fails and the cluster stays stuck inBootstrapforever.CLUSTER ADDSLOTSRANGE 0 16383— a single compact command with just a start-end range pair, avoiding the URL length issue entirelyCLUSTER ADDSLOTSinto chunks of 1000 per exec call.CLUSTER ADDSLOTSis idempotent for unassigned slots, so partial retries on the next reconcile are safe-a) and TLS flags are handled per-call since the single-leader path now executes independentlydefault:(multi-leader) path is unchanged in behaviorTest plan
TestSingleLeaderAddSlotsBatchingvalidates all 16384 slots are covered across 17 batches with no gaps or overlaps (v6 fallback path)go test ./internal/k8sutils/...)clusterSize: 1on Redis 7, verify it bootstraps with ADDSLOTSRANGEclusterSize: 3, verify multi-leader bootstrap is unaffected