Skip to content

Commit 4d81622

Browse files
committed
Compare major version number numerically
# Changes This makes a numerical comparison for the major version number when launching redis in cluster mode. This is to make sure that we don't end up in the first block after the if statement when running Redis newer than v7, as v8 is now out.
1 parent 1c4f2aa commit 4d81622

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

entrypoint.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ tls_setup() {
6868
echo tls-cluster yes
6969
} >> /etc/redis/redis.conf
7070

71-
if [[ "${REDIS_MAJOR_VERSION}" == "v7" ]]; then
71+
# Extract numeric version by removing 'v' prefix
72+
VERSION_NUMBER="${REDIS_MAJOR_VERSION#v}"
73+
if [[ "${VERSION_NUMBER}" -ge 7 ]]; then
7274
{
7375
echo cluster-preferred-endpoint-type hostname
7476
} >> /etc/redis/redis.conf
@@ -142,11 +144,16 @@ start_redis() {
142144
else
143145
CLUSTER_ANNOUNCE_IP="${POD_IP}"
144146
fi
145-
146-
if [[ "${REDIS_MAJOR_VERSION}" != "v7" ]]; then
147+
148+
# Extract numeric version by removing 'v' prefix
149+
VERSION_NUMBER="${REDIS_MAJOR_VERSION#v}"
150+
151+
if [[ "${VERSION_NUMBER}" -lt 7 ]]; then
152+
# IP-only mode for Redis v6 and older
147153
exec redis-server /etc/redis/redis.conf \
148154
--cluster-announce-ip "${CLUSTER_ANNOUNCE_IP}"
149155
else
156+
# Hostname mode for Redis v7 and newer
150157
{
151158
echo cluster-announce-ip "${CLUSTER_ANNOUNCE_IP}"
152159
echo cluster-announce-hostname "${POD_HOSTNAME}"

0 commit comments

Comments
 (0)