Merge pull request #4256 from nextcloud/enh/noid/harden-pulling-images

harden pulling images from docker hub issues
This commit is contained in:
Simon L 2024-02-20 15:47:56 +01:00 committed by GitHub
commit 5e86d7baaf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 0 deletions

View file

@ -48,6 +48,15 @@ class DockerController
}
}
// Check if docker hub is reachable in order to make sure that we do not try to pull an image if it is down
// and try to mitigate issues that are arising due to that
if ($pullImage) {
if (!$this->dockerActionManager->isDockerHubReachable($container)) {
$pullImage = false;
error_log('Not pulling the image for the ' . $container->GetContainerName() . ' container because docker hub does not seem to be reachable.');
}
}
$this->dockerActionManager->DeleteContainer($container);
$this->dockerActionManager->CreateVolumes($container);
if ($pullImage) {

View file

@ -587,6 +587,21 @@ class DockerActionManager
}
public function isDockerHubReachable(Container $container) : bool {
$tag = $container->GetImageTag();
if ($tag === '%AIO_CHANNEL%') {
$tag = $this->GetCurrentChannel();
}
$remoteDigest = $this->dockerHubManager->GetLatestDigestOfTag($container->GetContainerName(), $tag);
if ($remoteDigest === null) {
return false;
} else {
return true;
}
}
public function PullImage(Container $container) : void
{
$imageName = $this->BuildImageName($container);