Skip to content
Open
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
8 changes: 6 additions & 2 deletions bitnami/redis/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Changelog

## 23.0.4 (2025-10-23)
## 23.0.5 (2025-10-25)

* [bitnami/redis] Fix automatic sentinel failover not triggering on graceful shutdown ([#36362](https://github.com/bitnami/charts/pull/36362))
* [bitnami/redis] Add support to redis master service with useHostnames false ([#35536](https://github.com/bitnami/charts/pull/35536))

## <small>23.0.4 (2025-10-24)</small>

* [bitnami/redis] Fix automatic sentinel failover not triggering on graceful shutdown (#36362) ([75c2a2c](https://github.com/bitnami/charts/commit/75c2a2cdf9c17094b46ad3a968ea700a241673b6)), closes [#36362](https://github.com/bitnami/charts/issues/36362)

## <small>23.0.3 (2025-10-20)</small>

Expand Down
2 changes: 1 addition & 1 deletion bitnami/redis/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ maintainers:
name: redis
sources:
- https://github.com/bitnami/charts/tree/main/bitnami/redis
version: 23.0.4
version: 23.0.5
99 changes: 75 additions & 24 deletions bitnami/redis/templates/scripts-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,11 @@ data:
{{- if or .Values.sentinel.masterService.enabled .Values.sentinel.service.createMaster }}
if [[ "${REDIS_REPLICATION_MODE}" == "master" ]]; then
# Add isMaster label to master node for master service
{{- if .Values.useHostnames }}
echo "${REDIS_MASTER_HOST/.*}" > /etc/shared/current
{{- else }}
echo "${REDIS_MASTER_HOST}" > /etc/shared/current
{{- end }}
fi
{{- end }}

Expand Down Expand Up @@ -815,12 +819,17 @@ data:
fi

{{- if or .Values.sentinel.masterService.enabled .Values.sentinel.service.createMaster }}
push-master-label.sh: |
#!/bin/bash
# https://download.redis.io/redis-stable/sentinel.conf

echo "${6/.*}" > /etc/shared/current
echo "${4/.*}" > /etc/shared/previous
push-master-label.sh: |
#!/bin/bash
# https://download.redis.io/redis-stable/sentinel.conf

{{- if .Values.useHostnames }}
echo "${6/.*}" > /etc/shared/current
echo "${4/.*}" > /etc/shared/previous
{{- else }}
echo "$6" > /etc/shared/current
echo "$4" > /etc/shared/previous
{{- end }}
Comment on lines +822 to +832
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please correct me if I'm wrong but this change in the indentation is unexpected:

Suggested change
push-master-label.sh: |
#!/bin/bash
# https://download.redis.io/redis-stable/sentinel.conf
{{- if .Values.useHostnames }}
echo "${6/.*}" > /etc/shared/current
echo "${4/.*}" > /etc/shared/previous
{{- else }}
echo "$6" > /etc/shared/current
echo "$4" > /etc/shared/previous
{{- end }}
push-master-label.sh: |
#!/bin/bash
# https://download.redis.io/redis-stable/sentinel.conf
{{- if .Values.useHostnames }}
echo "${6/.*}" > /etc/shared/current
echo "${4/.*}" > /etc/shared/previous
{{- else }}
echo "$6" > /etc/shared/current
echo "$4" > /etc/shared/previous
{{- end }}

{{- end }}
{{- else }}
start-master.sh: |
Expand Down Expand Up @@ -1008,25 +1017,67 @@ metadata:
data:
update-master-label.sh: |
#!/bin/bash
while true; do
while [ ! -f "/etc/shared/current" ] && [ ! -f "/etc/shared/terminate" ]; do
sleep 1
done
set -euo pipefail

LOCK_FILE="/etc/shared/update-master-label.lock"

main_logic() {
while true; do
while [ ! -f "/etc/shared/current" ] && [ ! -f "/etc/shared/terminate" ]; do
sleep 1
done

if [ -f "/etc/shared/current" ]; then
current_master=$(< /etc/shared/current)
previous_master=""
[ -f /etc/shared/previous ] && previous_master=$(< /etc/shared/previous)

echo "Current master: $current_master"

if [ "$current_master" = "$previous_master" ]; then
echo "Master has not changed, skipping label update and cleaning state"
rm -f /etc/shared/current /etc/shared/previous
continue
fi

{{- if .Values.useHostnames }}
selector_key="metadata.name"
{{- else }}
selector_key="status.podIP"
{{- end }}

if [ -n "$current_master" ]; then
echo "Labeling new master $current_master"
kubectl label pod --field-selector="$selector_key=$current_master" isMaster="true" --overwrite || echo "Failed to label master"
kubectl label pod --field-selector="$selector_key=$current_master" app.kubernetes.io/role- || echo "Failed to remove role label"
fi

if [ -n "$previous_master" ]; then
echo "Previous master: $previous_master"
echo "Removing master label from previous master $previous_master"
kubectl label pod --field-selector="$selector_key=$previous_master" isMaster="false" --overwrite || echo "Failed to remove label"
fi

if [ -f "/etc/shared/current" ]; then
echo "new master elected, updating label(s)..."
kubectl label pod --field-selector metadata.name="$(< "/etc/shared/current")" isMaster="true" --overwrite
kubectl label pod --field-selector metadata.name="$(< "/etc/shared/current")" app.kubernetes.io/role-
if [ -f /etc/shared/previous ]; then
kubectl label pod --field-selector metadata.name="$(< "/etc/shared/previous")" isMaster="false" --overwrite
echo "Cleaning state files"
rm -f /etc/shared/current /etc/shared/previous
fi
rm "/etc/shared/current" "/etc/shared/previous"
fi

if [ -f "/etc/shared/terminate" ]; then
echo "received signal to terminate"
rm "/etc/shared/terminate"
exit
fi
done
if [ -f "/etc/shared/terminate" ]; then
echo "Terminating on request"
rm "/etc/shared/terminate"
exit
fi
done
}

export -f main_logic

if command -v flock &> /dev/null; then
echo "flock found. Using lock file $LOCK_FILE to prevent race conditions."
flock -n "$LOCK_FILE" bash -c "main_logic"
else
echo "WARNING: flock command not found in the system. Running without lock."
echo "This could cause race conditions in a multi-replica setup."
main_logic
fi
{{- end }}
Loading