Skip to content

feat(sentinel): report Sentinel peers and masters that are not pods of the RedisFailover - #335

Merged
Saremox merged 4 commits into
mainfrom
claude/sentinel-foreign-detect
Oct 19, 2026
Merged

Saremox merged 4 commits into
mainfrom
claude/sentinel-foreign-detect

Conversation

@Saremox

@Saremox Saremox commented Oct 19, 2026

Copy link
Copy Markdown
Owner

Changes proposed on the PR:

  • Give the Sentinel master name one source (DefaultSentinelMasterName, SentinelMasterName) for sentinel.conf, the readiness probe and the shutdown script. The generated objects do not change. Correction: the first commit message says "a change in one place", but service/redis/client.go still uses the constant. A name per RedisFailover needs a name parameter on the Sentinel methods of Client. Literals that can drift: example/redisfailover/custom-shutdown.yaml (lines 34 and 65); README.md (lines 280, 284 and 701); docs/migrations/4.2.0.md (line 445); the comment at api/redisfailover/v1/types.go line 281 and in the 3 CRD yamls; the comment at service/redis/sentinel.go line 282.
  • In Sentinel mode, read SENTINEL MASTER and SENTINEL SENTINELS from each running Sentinel, before the count of the masters, with short timeouts. All RedisFailovers use mymaster, so the Sentinels of two RedisFailovers can merge into one group and exchange masters. The soak merged two instances for 30 minutes.
  • Report a peer IP that is no Sentinel pod, and a master IP that is no Redis pod, when no pod of the RedisFailover had it in the last 5 minutes. The report needs two checks at least 90 seconds apart. It gives a Warning at the start, an Info at the end, and the gauges redis_operator_controller_unknown_sentinel_peers and redis_operator_controller_sentinel_unknown_master. A reconcile without the check sets them to 0. The IPs compare in standard form, also for dual-stack pods. The operator changes no status, role or Sentinel.
  • Document the check in docs/logic.md and the gauges in the README.

Tests: TestSentinelMasterNameHasOneDefinition (fails on main), TestObserveSentinelAddrs, TestObserveSentinelAddrsPrunesThePodIPs, TestSkipSentinelAddrs*, TestSentinelAddrsOnlyInSentinelMode, TestGetUnknownSentinelAddrs*, TestGetSentinelPeers* (one uses two real Sentinels, one a frozen Sentinel), TestSentinelUnknownAddrsMetrics. The new tests do not compile on main; mutations of each rule fail them. Not tested: a real cluster, and a real merge of two groups.


Generated by Claude Code

The Sentinel config, the Sentinel readiness probe, the shutdown script
and the Redis client each had their own copy of `mymaster`. They take
the name from `DefaultSentinelMasterName` through `SentinelMasterName`,
so a name per RedisFailover needs a change in one place. The generated
objects do not change.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G4mmyo3sqLwf23m5FE2nBE
…f the RedisFailover

All RedisFailovers use one Sentinel master name, and a Sentinel accepts
each peer that sends this name. A Sentinel of another RedisFailover at
an old IP of an own Sentinel merges the two groups, and the groups then
exchange their masters. The operator compared only counts and did not
see such a merge.

In Sentinel mode, each reconcile reads SENTINEL MASTER and SENTINEL
SENTINELS from each running Sentinel, before the count of the masters.
A peer that is no Sentinel pod and a master that is no Redis pod of the
RedisFailover are unknown. An IP counts after two checks at least 10s
apart. The operator logs a Warning at the start and an Info at the end,
and sets the gauges unknown_sentinel_peers and sentinel_unknown_master.
It changes no status, no role and no Sentinel.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G4mmyo3sqLwf23m5FE2nBE
…entinel addresses

The other Sentinels keep a deleted Sentinel as a peer until their reset,
which can come 55s or more after the deletion. A report after 10s thus
gave a Warning in each Sentinel restart and rollout.

- An IP counts after two checks at least 90s apart.
- The operator keeps each pod IP of the RedisFailover for 5 minutes after
  the last check that found it. Such an IP is not unknown.
- A Sentinel in deletion without an answer does not stop the end of an
  address, because on a lost node it never answers.
- A reconcile without the check ends the report and sets the gauges to 0.
- The IPs compare in their standard form, and a dual-stack pod has both IPs.
- The read uses the short timeouts without a retry, because an error only
  leaves the Sentinel unread for one check.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G4mmyo3sqLwf23m5FE2nBE
The test of the old IP gives the address in each check, so a check
without the memory of the pod IPs reports it after 90s.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G4mmyo3sqLwf23m5FE2nBE

Saremox commented Oct 19, 2026

Copy link
Copy Markdown
Owner Author

@codex review


Generated by Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T20:28:20.480593Z a5512c9 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@codecov

codecov Bot commented Oct 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.42857% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ator/redisfailover/service/check_sentinel_peers.go 97.56% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: a5512c9b4c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@Saremox
Saremox merged commit 16018e4 into main Oct 19, 2026
17 checks passed
@Saremox
Saremox deleted the claude/sentinel-foreign-detect branch October 19, 2026 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants