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:
Simon L. 2026-01-19 15:21:28 +01:00
parent b88c740161
commit f58465f930

View file

@ -503,14 +503,24 @@ readonly class DockerActionManager {
} catch (\Throwable $e) { } catch (\Throwable $e) {
$imageIsThere = false; $imageIsThere = false;
} }
try {
$this->guzzleClient->post($url); $maxRetries = 3;
} catch (RequestException $e) { for ($attempt = 1; $attempt <= $maxRetries; $attempt++) {
$message = "Could not pull image " . $imageName . ": " . $e->getResponse()?->getBody()->getContents(); try {
if ($imageIsThere === false) { $this->guzzleClient->post($url);
throw new \Exception($message); break;
} else { } catch (RequestException $e) {
error_log($message); $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);
}
} }
} }
} }