fix(database): make the Redis health check ping with the password

The check was [CMD-SHELL, redis-cli, ping], so Docker ran only redis-cli
and it always passed. redis-cli also exits 0 on NOAUTH and LOADING.
The check now pings with the server password and requires PONG. With a
custom redis.conf that sets its own requirepass, it requires PONG or NOAUTH.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Andras Bacsai
2026-11-06 12:37:36 +01:00
co-authored by Claude Opus 5.5
parent 5960814df5
commit 878d77bd66
+15 -2
View File
@@ -108,8 +108,7 @@ class StartRedis
'labels' => defaultDatabaseLabels($this->database)->toArray(),
'healthcheck' => $this->database->healthCheckConfiguration([
'CMD-SHELL',
'redis-cli',
'ping',
$this->healthCheckCommand(),
]),
'mem_limit' => $this->database->limits_memory,
'memswap_limit' => $this->database->limits_memory_swap,
@@ -340,6 +339,20 @@ class StartRedis
return $keepsUnquotedPassword ? $this->resolvedRedisPassword : escapeshellarg($this->resolvedRedisPassword);
}
/**
* The healthcheck pings with the server password and requires PONG, because redis-cli exits 0 on
* error replies (NOAUTH, LOADING). A custom redis.conf with its own requirepass has a password that
* Coolify does not know, so that check only requires that the server replies.
*/
private function healthCheckCommand(): string
{
if (str_contains((string) $this->database->redis_conf, 'requirepass')) {
return "redis-cli ping | grep -qE 'PONG|NOAUTH'";
}
return 'redis-cli -a '.$this->requirePassArgument().' --no-auth-warning ping | grep -q PONG';
}
private function add_custom_redis()
{
if (is_null($this->database->redis_conf) || empty($this->database->redis_conf)) {