diff --git a/lib/DeployActions/DockerActions.php b/lib/DeployActions/DockerActions.php index 87dc30e9..346ff9d0 100644 --- a/lib/DeployActions/DockerActions.php +++ b/lib/DeployActions/DockerActions.php @@ -96,7 +96,7 @@ public function buildBaseImageName(array $imageParams): string { $imageParams['image_name'] . ':' . $imageParams['image_tag']; } - public function buildExtendedImageName(array $imageParams, DaemonConfig $daemonConfig): ?string { + private function buildExtendedImageName(array $imageParams, DaemonConfig $daemonConfig): ?string { if (empty($daemonConfig->getDeployConfig()['computeDevice']['id'])) { return null; } @@ -104,6 +104,14 @@ public function buildExtendedImageName(array $imageParams, DaemonConfig $daemonC $imageParams['image_name'] . '-' . $daemonConfig->getDeployConfig()['computeDevice']['id'] . ':' . $imageParams['image_tag']; } + private function buildExtendedImageName2(array $imageParams, DaemonConfig $daemonConfig): ?string { + if (empty($daemonConfig->getDeployConfig()['computeDevice']['id'])) { + return null; + } + return $imageParams['image_src'] . '/' . + $imageParams['image_name'] . ':' . $imageParams['image_tag'] . '-' . $daemonConfig->getDeployConfig()['computeDevice']['id']; + } + public function createContainer(string $dockerUrl, string $imageId, array $params = []): array { $createVolumeResult = $this->createVolume($dockerUrl, $this->buildExAppVolumeName($params['name'])); if (isset($createVolumeResult['error'])) { @@ -210,18 +218,33 @@ public function removeContainer(string $dockerUrl, string $containerId): string public function pullImage( string $dockerUrl, array $params, ExApp $exApp, int $startPercent, int $maxPercent, DaemonConfig $daemonConfig, string &$imageId ): string { - $imageId = $this->buildExtendedImageName($params, $daemonConfig); - if ($imageId === null) { - $imageId = $this->buildBaseImageName($params); - $this->logger->info(sprintf('Pulling "base" image: %s', $imageId)); - } - try { - $r = $this->pullImageInternal($dockerUrl, $exApp, $startPercent, $maxPercent, $imageId); - } catch (GuzzleException $e) { - $r = sprintf('Failed to pull image, GuzzleException occur: %s', $e->getMessage()); + $imageId = $this->buildExtendedImageName2($params, $daemonConfig); + if ($imageId) { + try { + $r = $this->pullImageInternal($dockerUrl, $exApp, $startPercent, $maxPercent, $imageId); + if ($r === '') { + $this->logger->info(sprintf('Successfully pulled "extended" image in a new name format: %s', $imageId)); + return ''; + } + } catch (GuzzleException $e) { + $this->logger->info( + sprintf('Failed to pull "extended" image(%s), GuzzleException occur: %s', $imageId, $e->getMessage()) + ); + } } - if (($r === '') || ($imageId === $this->buildBaseImageName($params))) { - return $r; + $imageId = $this->buildExtendedImageName($params, $daemonConfig); // TODO: remove with drop of NC29 support + if ($imageId) { + try { + $r = $this->pullImageInternal($dockerUrl, $exApp, $startPercent, $maxPercent, $imageId); + if ($r === '') { + $this->logger->info(sprintf('Successfully pulled "extended" image in an old name format: %s', $imageId)); + return ''; + } + } catch (GuzzleException $e) { + $this->logger->info( + sprintf('Failed to pull "extended" image(%s), GuzzleException occur: %s', $imageId, $e->getMessage()) + ); + } } $this->logger->info(sprintf('Failed to pull "extended" image for %s: %s', $imageId, $r)); $this->logger->info(sprintf('Pulling "base" image: %s', $imageId));