Skip to content
Merged
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
fix(Podman-HealthCheck): treat empty health status as success.
Signed-off-by: Oleksander Piskun <oleksandr2088@icloud.com>
  • Loading branch information
oleksandr-nc committed Jun 4, 2025
commit 55f2c1a5da1b0465dd1e043990e72c375de201cd
24 changes: 13 additions & 11 deletions lib/DeployActions/DockerActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1207,24 +1207,26 @@ public function waitTillContainerStart(string $containerId, DaemonConfig $daemon

public function healthcheckContainer(string $containerId, DaemonConfig $daemonConfig, bool $waitForSuccess): bool {
$dockerUrl = $this->buildDockerUrl($daemonConfig);
$containerInfo = $this->inspectContainer($dockerUrl, $containerId);
if (!isset($containerInfo['State']['Health']['Status'])) {
return true; // container does not support Healthcheck
}
if (!$waitForSuccess) {
return $containerInfo['State']['Health']['Status'] === 'healthy';
}
$maxTotalAttempts = 900;
$maxTotalAttempts = $waitForSuccess ? 900 : 1;
while ($maxTotalAttempts > 0) {
$containerInfo = $this->inspectContainer($dockerUrl, $containerId);
if ($containerInfo['State']['Health']['Status'] === 'healthy') {
if (!isset($containerInfo['State']['Health']['Status'])) {
return true; // container does not support Healthcheck
}
$status = $containerInfo['State']['Health']['Status'];
if ($status === '') {
return true; // we treat empty status as 'success', see https://github.com/nextcloud/app_api/issues/439
}
if ($status === 'healthy') {
return true;
}
if ($containerInfo['State']['Health']['Status'] === 'unhealthy') {
if ($status === 'unhealthy') {
return false;
}
$maxTotalAttempts--;
sleep(1);
if ($maxTotalAttempts > 0) {
sleep(1);
}
}
return false;
}
Expand Down