fix(redis): keep three Sentinels for a zero or negative replica count

The operator runs three Redis pods when the count is zero or negative, but the chart treated any count up to 1 as the single-pod case. Such a cluster got one Sentinel and no Sentinel PDB, while three Redis pods ran under it.

Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
(cherry picked from commit a7f84242d1)
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
This commit is contained in:
Mattia Eleuteri authored and Myasnikov Daniil committed 2026-11-10 12:40:55 +00:00
1 parent ef2657a3fb
commit 32455168e2
3 files changed
+49 -1

No files matched your search

+1 -1
View File
@@ -49,5 +49,5 @@ These presets are for basic testing and not meant to be used in production
{{- end -}}
{{- define "redis.sentinelReplicas" -}}
{{- ternary 1 3 (le (int .Values.replicas) 1) -}}
{{- ternary 1 3 (eq (int .Values.replicas) 1) -}}
{{- end -}}
@@ -77,6 +77,26 @@ tests:
- hasDocuments:
count: 0
# The operator runs three Redis pods for a zero or negative count, so their
# Sentinel PDB stays.
- it: renders nothing for a zero replica count
release:
upgrade: true
set:
replicas: 0
asserts:
- hasDocuments:
count: 0
- it: renders nothing for a negative replica count
release:
upgrade: true
set:
replicas: -1
asserts:
- hasDocuments:
count: 0
# The pods' job-name label takes 63 characters at most; a 53-character
# release name plus -sentinel-pdb would pass it and Kubernetes would refuse
# the Job, leaving the stale PDB in place.
@@ -54,6 +54,34 @@ tests:
- notExists:
path: spec.sentinel.disablePodDisruptionBudget
# The operator turns a zero or negative count into three Redis pods, so these
# keep three Sentinels and their PDB rather than the single-pod case.
- it: "keeps three Sentinels and their PDB for a zero replica count"
set:
replicas: 0
documentSelector:
path: kind
value: RedisFailover
asserts:
- equal:
path: spec.sentinel.replicas
value: 3
- notExists:
path: spec.sentinel.disablePodDisruptionBudget
- it: "keeps three Sentinels and their PDB for a negative replica count"
set:
replicas: -1
documentSelector:
path: kind
value: RedisFailover
asserts:
- equal:
path: spec.sentinel.replicas
value: 3
- notExists:
path: spec.sentinel.disablePodDisruptionBudget
- it: "keeps three Sentinels for three Redis pods"
set:
replicas: 3