mirror of
https://github.com/nextcloud/all-in-one.git
synced 2026-02-04 04:56:52 +00:00
DockeractionManager: rewrite PullImage function to re-try 3 times before failing
Signed-off-by: Simon L. <szaimen@e.mail.de>
This commit is contained in:
parent
b88c740161
commit
f58465f930
1 changed files with 18 additions and 8 deletions
|
|
@ -503,14 +503,24 @@ readonly class DockerActionManager {
|
|||
} catch (\Throwable $e) {
|
||||
$imageIsThere = false;
|
||||
}
|
||||
try {
|
||||
$this->guzzleClient->post($url);
|
||||
} catch (RequestException $e) {
|
||||
$message = "Could not pull image " . $imageName . ": " . $e->getResponse()?->getBody()->getContents();
|
||||
if ($imageIsThere === false) {
|
||||
throw new \Exception($message);
|
||||
} else {
|
||||
error_log($message);
|
||||
|
||||
$maxRetries = 3;
|
||||
for ($attempt = 1; $attempt <= $maxRetries; $attempt++) {
|
||||
try {
|
||||
$this->guzzleClient->post($url);
|
||||
break;
|
||||
} catch (RequestException $e) {
|
||||
$message = "Could not pull image " . $imageName . " (attempt $attempt/$maxRetries): " . $e->getResponse()?->getBody()->getContents();
|
||||
if ($attempt === $maxRetries) {
|
||||
if ($imageIsThere === false) {
|
||||
throw new \Exception($message);
|
||||
} else {
|
||||
error_log($message);
|
||||
}
|
||||
} else {
|
||||
error_log($message . ' Retrying...');
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue