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
24 changes: 13 additions & 11 deletions lib/DeployActions/DockerActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -803,24 +803,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
Loading