Skip to content

sentinel: don't announce-ip 0.0.0.0 when using hostname discovery#1750

Open
SAY-5 wants to merge 1 commit intoOT-CONTAINER-KIT:mainfrom
SAY-5:fix/sentinel-announce-ip-0.0.0.0-1748
Open

sentinel: don't announce-ip 0.0.0.0 when using hostname discovery#1750
SAY-5 wants to merge 1 commit intoOT-CONTAINER-KIT:mainfrom
SAY-5:fix/sentinel-announce-ip-0.0.0.0-1748

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented Apr 21, 2026

Summary

Fixes #1748.

With announceHostnames=yes + resolveHostnames=yes, the initContainer wrote sentinel announce-ip <ip> using whatever value the IP env variable held. The operator doesn't set IP on the Sentinel pod, so CoalesceEnv("IP", "0.0.0.0") returned the 0.0.0.0 default and that ended up in sentinel.conf - Sentinels then broadcast 0.0.0.0 to peers and could not find each other, silently short-circuiting hostname discovery.

Fix

Emit the announce-ip line only when we actually have a usable IP (i.e. the operator has set IP to something other than "" / 0.0.0.0), and rely on announce-hostnames + resolve-hostnames otherwise. When both hostname modes are on without a real IP, Redis Sentinel auto-discovers via DNS, which is exactly the intent of the feature.

Deployments that do set an IP explicitly (direct-IP mode or dual-stack configurations where IP is propagated) keep the previous behaviour.

Test plan

  • go build ./internal/agent/...
  • Traced both config paths:
    • announceHostnames=yes + resolveHostnames=yes + IP unset → no announce-ip line, hostname discovery works
    • announceHostnames=yes + resolveHostnames=yes + IP=10.0.0.42announce-ip 10.0.0.42 line retained
    • announceHostnames=no → unchanged

With announceHostnames=yes + resolveHostnames=yes the initContainer
wrote `sentinel announce-ip <ip>` using whatever value the IP env
variable held. The operator doesn't set IP on the Sentinel pod,
so the CoalesceEnv default 0.0.0.0 ended up in sentinel.conf and
Sentinels could not discover each other - hostname discovery was
silently short-circuited (OT-CONTAINER-KIT#1748).

Emit the announce-ip line only when we actually have a usable IP
(i.e. the operator has set IP to something other than the ""/
0.0.0.0 default), and rely on announce-hostnames +
resolve-hostnames otherwise. When both hostname modes are on
without a real IP, Redis Sentinel auto-discovers via DNS, which
is exactly the intent of the feature.

Signed-off-by: SAY-5 <SAY-5@users.noreply.github.com>
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.

Sentinel announce-ip set to 0.0.0.0 when announceHostnames and resolveHostnames are enabled

1 participant