Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions charts/valkey/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -335,22 +335,25 @@ data:
# cold-start hint: if a failover already happened and this pod lost its
# emptyDir, monitoring node-0 again would advertise a stale master until
# hello-channel gossip converges. Probe the data plane for the real master.
master="$SEED_MASTER"
# Discover the node currently reporting role:master, not merely a reachable
# seed. After a failover the seed (node-0) is a live *replica*, and a
# Sentinel seeded on a replica never redirects to the real master — it would
# advertise that replica to clients. Fall back to the seed only if no node
# answers as master within the bounded budget.
master=""
i=0
until vcli -h "$master" -p "$VALKEY_PORT" ping >/dev/null 2>&1; do
i=$((i + 1))
while :; do
if m="$(find_current_master)"; then
if [ "$m" != "$master" ]; then
echo "seed $master unavailable; using discovered master $m"
master="$m"
continue
fi
master="$m"
break
fi
i=$((i + 1))
if [ "$i" -ge 6 ]; then
echo "no reachable master after bounded wait; monitoring seed $master anyway"
master="$SEED_MASTER"
echo "no master discovered after bounded wait; monitoring seed $master anyway"
break
fi
echo "waiting for master $master:$VALKEY_PORT ($i/6)"
echo "waiting to discover current master ($i/6)"
sleep 3
done
cp "$BASE" "$CONF"
Expand Down
3 changes: 3 additions & 0 deletions charts/valkey/tests/cluster_domain_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ tests:
path: data["sentinel-entrypoint.sh"]
pattern: 'SEED_MASTER="test-valkey-node-0\.test-valkey-headless\.valkey-ns\.svc\.corp\.internal"'
- matchRegex:
path: data["sentinel-entrypoint.sh"]
pattern: 'if m="\$\(find_current_master\)"; then[\s\S]*?master="\$m"'
- notMatchRegex:
path: data["sentinel-entrypoint.sh"]
pattern: 'until vcli -h "\$master" -p "\$VALKEY_PORT" ping'

Expand Down
2 changes: 1 addition & 1 deletion charts/valkey/tests/ha_extension_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ tests:
template: configmap.yaml
- matchRegex:
path: data["sentinel-entrypoint.sh"]
pattern: 'if \[ ! -f "\$CONF" \]; then[\s\S]*?until vcli'
pattern: 'if \[ ! -f "\$CONF" \]; then[\s\S]*?find_current_master'
template: configmap.yaml
- matchRegex:
path: data["sentinel-entrypoint.sh"]
Expand Down