Skip to content

Commit c5a0dd2

Browse files
authored
Merge pull request #589 from nextcloud/backport/588/stable31
[stable31] fix(Podman-HealthCheck): treat empty health status as success.
2 parents f762e59 + f4ce143 commit c5a0dd2

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

lib/DeployActions/DockerActions.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -803,24 +803,26 @@ public function waitTillContainerStart(string $containerId, DaemonConfig $daemon
803803

804804
public function healthcheckContainer(string $containerId, DaemonConfig $daemonConfig, bool $waitForSuccess): bool {
805805
$dockerUrl = $this->buildDockerUrl($daemonConfig);
806-
$containerInfo = $this->inspectContainer($dockerUrl, $containerId);
807-
if (!isset($containerInfo['State']['Health']['Status'])) {
808-
return true; // container does not support Healthcheck
809-
}
810-
if (!$waitForSuccess) {
811-
return $containerInfo['State']['Health']['Status'] === 'healthy';
812-
}
813-
$maxTotalAttempts = 900;
806+
$maxTotalAttempts = $waitForSuccess ? 900 : 1;
814807
while ($maxTotalAttempts > 0) {
815808
$containerInfo = $this->inspectContainer($dockerUrl, $containerId);
816-
if ($containerInfo['State']['Health']['Status'] === 'healthy') {
809+
if (!isset($containerInfo['State']['Health']['Status'])) {
810+
return true; // container does not support Healthcheck
811+
}
812+
$status = $containerInfo['State']['Health']['Status'];
813+
if ($status === '') {
814+
return true; // we treat empty status as 'success', see https://github.com/nextcloud/app_api/issues/439
815+
}
816+
if ($status === 'healthy') {
817817
return true;
818818
}
819-
if ($containerInfo['State']['Health']['Status'] === 'unhealthy') {
819+
if ($status === 'unhealthy') {
820820
return false;
821821
}
822822
$maxTotalAttempts--;
823-
sleep(1);
823+
if ($maxTotalAttempts > 0) {
824+
sleep(1);
825+
}
824826
}
825827
return false;
826828
}

0 commit comments

Comments
 (0)