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
Open
sentinel: don't announce-ip 0.0.0.0 when using hostname discovery#1750SAY-5 wants to merge 1 commit intoOT-CONTAINER-KIT:mainfrom
SAY-5 wants to merge 1 commit intoOT-CONTAINER-KIT:mainfrom
Conversation
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>
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 #1748.
With
announceHostnames=yes+resolveHostnames=yes, the initContainer wrotesentinel announce-ip <ip>using whatever value theIPenv variable held. The operator doesn't setIPon the Sentinel pod, soCoalesceEnv("IP", "0.0.0.0")returned the0.0.0.0default and that ended up insentinel.conf- Sentinels then broadcast0.0.0.0to peers and could not find each other, silently short-circuiting hostname discovery.Fix
Emit the
announce-ipline only when we actually have a usable IP (i.e. the operator has setIPto something other than""/0.0.0.0), and rely onannounce-hostnames+resolve-hostnamesotherwise. 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
IPis propagated) keep the previous behaviour.Test plan
go build ./internal/agent/...announceHostnames=yes + resolveHostnames=yes + IP unset→ noannounce-ipline, hostname discovery worksannounceHostnames=yes + resolveHostnames=yes + IP=10.0.0.42→announce-ip 10.0.0.42line retainedannounceHostnames=no→ unchanged