Repository navigation
refactor(checker): split the reconcile functions and checker.go by topic - #322
Conversation
UpdateRedisesPods: cyclomatic 49 -> 12, cognitive 109 -> 13, length 177 -> 47 lines. The replica scan, the replica replacement, the master replacement and the gate before the master delete are helpers. No behavior change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G4mmyo3sqLwf23m5FE2nBE
checkAndHeal: cyclomatic 48 -> 5, cognitive 89 -> 5, length 368 -> 50 lines. The Sentinel-managed mode, the master count, the election without a Sentinel failover, the config and rollout step and the Sentinel monitor step are helpers. stoppingMasterStatus and setOldestAsMaster replace copies of the same code. No behavior change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G4mmyo3sqLwf23m5FE2nBE
checkAndHealOperatorManagedMode: cyclomatic 41 -> 9, cognitive 87 -> 8, length 268 -> 37 lines. Each master count has a helper. The redis quorum check, the config and rollout step, the stopping master check, the master pod wait and the status of a failed promotion use the helpers of the Sentinel-managed mode. No behavior change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G4mmyo3sqLwf23m5FE2nBE
…pMode checkAndHealBootstrapMode: cyclomatic 16 -> 8, cognitive 33 -> 8, length 104 -> 59 lines. healBootstrapSentinels holds the Sentinel monitor step of the bootstrap mode. No behavior change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G4mmyo3sqLwf23m5FE2nBE
applyPassword: cyclomatic 31 -> 14, cognitive 34 -> 12, length 68 -> 36 lines. applyRedisPassword and applySentinelPassword hold the two steps, and passwordState.current holds the check of a state with nothing to do. No behavior change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G4mmyo3sqLwf23m5FE2nBE
checkAndHealSentinels: cyclomatic 18 -> 10, cognitive 32 -> 14, length 73 -> 41 lines. restoreSentinelMismatches holds the loop that the Sentinel count and the replica count checks shared. No behavior change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G4mmyo3sqLwf23m5FE2nBE
readSentinelFailovers: cyclomatic 24 -> 13, cognitive 27 -> 13, length 88 -> 61 lines. findSentinelFailover reads the Sentinels and returns the failover of the leader, and sentinelFailover.continues compares it with the stored one. No behavior change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G4mmyo3sqLwf23m5FE2nBE
checker.go: 2374 -> 355 lines. The declarations move without a change to checker_rollout.go (pod rollout and master handover), checker_master.go (master pod state and failover timeout), checker_password.go, checker_sentinel_mode.go, checker_operator_mode.go and checker_sentinel.go (Sentinel heal and failover hold). Each file has less than 800 lines. No behavior change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G4mmyo3sqLwf23m5FE2nBE
The doc comments of rolloutScan, replaceStaleReplica and waitForMasterPod name the caller that returns on each result. Comment change only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G4mmyo3sqLwf23m5FE2nBE
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
TestOperatorElectedText read only checker.go. The split of checker.go moved the status message of electMasterForSentinel to checker_sentinel_mode.go, so the test failed. The test reads each checker*.go file of the package. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G4mmyo3sqLwf23m5FE2nBE
TestOperatorElectedText reads the status text from each checker*.go file, so the path filter of the soak job matches all of them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G4mmyo3sqLwf23m5FE2nBE
|
@codex review Generated by Claude Code |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Changes proposed on the PR:
Split
UpdateRedisesPods,checkAndHeal,checkAndHealOperatorManagedMode,checkAndHealBootstrapMode,applyPassword,checkAndHealSentinelsandreadSentinelFailoversinto helpers, so that each function has a cyclomatic complexity of at most 15, a cognitive complexity of at most 20 and at most 80 lines.Replace the copies of the stopping master check (5), the oldest pod election (3), the config and rollout step (2), the Sentinel quorum check (2) and the status of a failed promotion (3) with one helper each, to remove duplicated code.
Move the declarations of
checker.gowithout a change to topic files (rollout, master, password, Sentinel-managed mode, operator-managed mode, Sentinel heal), so that each file has less than 800 lines. An AST script checked that all 101 declarations are byte-identical.TestOperatorElectedText(soak module) reads the status text fromchecker.go. The text moved tochecker_sentinel_mode.go, so the test now reads allchecker*.gofiles, and the CI path filter of the soak job isoperator/redisfailover/checker*.go(it waschecker.go), so that the soak job runs when a split file changes. The first CI run of this PR failed on that test.No change of behavior: no exported identifier, message text, metric, log line, defer order or call order changed. User-visible effect: none.
Evidence:
operator/redisfailoverpass unchanged with 100% statement coverage of the checker files, also with-race.Not tested: a cluster run (kind, minikube); the Sentinel-unreachable branch inside
findSentinelFailoverunder the failover model.Found and not changed:
reportRolloutWaitusestime.Nowandtime.Since, not the handler clockr.now(). A fake clock never reaches the rollout stall message.🤖 Generated with Claude Code
https://claude.ai/code/session_01G4mmyo3sqLwf23m5FE2nBE
Generated by Claude Code