Skip to content

Commit

Permalink
Fix command line for Redis liveness probe
Browse files Browse the repository at this point in the history
redis-cli requires the command argument to be passed after the
credentials. Also (at least on 6.x versions) it does not properly return
an error status on authentication failures. This causes the liveness
probe to always return success. Fix this by checking for a PONG response
to a PING.
  • Loading branch information
mpihlak committed Apr 21, 2023
1 parent f027bb9 commit 8e94166
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion example/operator/custom-startup-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
data:
startup.sh: |
#!/bin/bash
redis-cli -h 127.0.0.1 -p ${REDIS_PORT} ping --user pinger --pass pingpass --no-auth-warning
redis-cli -h 127.0.0.1 -p ${REDIS_PORT} --user pinger --pass pingpass --no-auth-warning ping | grep PONG
---
apiVersion: databases.spotahome.com/v1
kind: RedisFailover
Expand Down
2 changes: 1 addition & 1 deletion operator/redisfailover/service/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ func generateRedisStatefulSet(rf *redisfailoverv1.RedisFailover, labels map[stri
Command: []string{
"sh",
"-c",
fmt.Sprintf("redis-cli -h $(hostname) -p %[1]v ping --user pinger --pass pingpass --no-auth-warning", rf.Spec.Redis.Port),
fmt.Sprintf("redis-cli -h $(hostname) -p %[1]v --user pinger --pass pingpass --no-auth-warning ping | grep PONG", rf.Spec.Redis.Port),
},
},
},
Expand Down
6 changes: 3 additions & 3 deletions operator/redisfailover/service/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1898,7 +1898,7 @@ func TestRedisCustomLivenessProbe(t *testing.T) {
Command: []string{
"sh",
"-c",
"redis-cli -h 127.0.0.1 -p ${REDIS_PORT} ping --user pinger --pass pingpass --no-auth-warning",
"redis-cli -h 127.0.0.1 -p ${REDIS_PORT} --user pinger --pass pingpass --no-auth-warning ping | grep PONG",
},
},
},
Expand All @@ -1913,7 +1913,7 @@ func TestRedisCustomLivenessProbe(t *testing.T) {
Command: []string{
"sh",
"-c",
"redis-cli -h 127.0.0.1 -p ${REDIS_PORT} ping --user pinger --pass pingpass --no-auth-warning",
"redis-cli -h 127.0.0.1 -p ${REDIS_PORT} --user pinger --pass pingpass --no-auth-warning ping | grep PONG",
},
},
},
Expand All @@ -1932,7 +1932,7 @@ func TestRedisCustomLivenessProbe(t *testing.T) {
Command: []string{
"sh",
"-c",
"redis-cli -h $(hostname) -p 6379 ping --user pinger --pass pingpass --no-auth-warning",
"redis-cli -h $(hostname) -p 6379 --user pinger --pass pingpass --no-auth-warning ping | grep PONG",
},
},
},
Expand Down

0 comments on commit 8e94166

Please sign in to comment.