From 8baae03287a3343909f14716c2da5728c1ad065a Mon Sep 17 00:00:00 2001 From: James Slagle Date: Fri, 12 Nov 2021 08:19:03 -0500 Subject: [PATCH] Skip Heat pod container image pull for default ephemeral heat images In overcloud deploy, there was logic to skip the container image pull when the default ephemeral Heat container images are being used. This is because the images have already been prepared and tagged as coming from the "localhost" repo. This patch adds that same logic in heat_launcher.py directly so that it can be used by both overcloud deploy and the launch heat command. The unit test method for the _fetch_container_image method is updated to test the additional logic. Change-Id: Ibea0751de50eeba932012467a5857cc3c783b611 Signed-off-by: James Slagle (cherry picked from commit 0b90f0dce86bc6d6cb6a0638d483dde020b02f23) --- tripleoclient/heat_launcher.py | 15 ++++++++++++++- tripleoclient/tests/test_heat_launcher.py | 14 ++++++++++++++ tripleoclient/v1/overcloud_deploy.py | 14 +------------- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/tripleoclient/heat_launcher.py b/tripleoclient/heat_launcher.py index d16544e54..768c75f56 100644 --- a/tripleoclient/heat_launcher.py +++ b/tripleoclient/heat_launcher.py @@ -37,6 +37,8 @@ from tenacity.wait import wait_fixed from tripleoclient.constants import (DEFAULT_HEAT_CONTAINER, DEFAULT_HEAT_API_CONTAINER, DEFAULT_HEAT_ENGINE_CONTAINER, + DEFAULT_EPHEMERAL_HEAT_API_CONTAINER, + DEFAULT_EPHEMERAL_HEAT_ENGINE_CONTAINER, DEFAULT_TEMPLATES_DIR, EPHEMERAL_HEAT_POD_NAME) from tripleoclient.exceptions import HeatPodMessageQueueException @@ -462,7 +464,18 @@ class HeatPodLauncher(HeatContainerLauncher): '-l', 's0', self.heat_dir]) def _fetch_container_image(self): - if self.skip_heat_pull: + # Skip trying to pull the images if they are set to the default + # as they can't be pulled since they are tagged as localhost. + # If the images are missing for some reason, podman will still pull + # them by default, and error appropriately if needed. + if (self.api_container_image == + DEFAULT_EPHEMERAL_HEAT_API_CONTAINER or + self.engine_container_image == + DEFAULT_EPHEMERAL_HEAT_ENGINE_CONTAINER): + skip_heat_pull = True + else: + skip_heat_pull = self.skip_heat_pull + if skip_heat_pull: log.info("Skipping container image pull.") return # force pull of latest container image diff --git a/tripleoclient/tests/test_heat_launcher.py b/tripleoclient/tests/test_heat_launcher.py index 7c117ec45..b3aa9a2e6 100644 --- a/tripleoclient/tests/test_heat_launcher.py +++ b/tripleoclient/tests/test_heat_launcher.py @@ -20,6 +20,7 @@ import shutil import subprocess import time +from tripleoclient import constants from tripleoclient import heat_launcher from tripleoclient.exceptions import HeatPodMessageQueueException from tripleoclient.tests import base @@ -69,10 +70,23 @@ class TestHeatPodLauncher(base.TestCase): launcher._fetch_container_image() self.assertFalse(self.check_calls('podman pull', self.check_output)) + # With skip_heat_pull=False, this should try and run the command to + # pull the default images from quay.io launcher = self.get_launcher(skip_heat_pull=False) launcher._fetch_container_image() self.assertTrue(self.check_calls('podman pull', self.check_output)) + # With skip_heat_pull=False, but using the default ephemeral heat + # container images, this should still skip the command to run the pull + launcher = self.get_launcher(skip_heat_pull=False) + launcher.api_container_image = \ + constants.DEFAULT_EPHEMERAL_HEAT_API_CONTAINER + launcher.engine_container_image = \ + constants.DEFAULT_EPHEMERAL_HEAT_ENGINE_CONTAINER + self.check_output.reset_mock() + launcher._fetch_container_image() + self.check_output.assert_not_called() + @mock.patch('tripleoclient.heat_launcher.HeatPodLauncher._decode') def test_get_pod_state(self, mock_decode): launcher = self.get_launcher() diff --git a/tripleoclient/v1/overcloud_deploy.py b/tripleoclient/v1/overcloud_deploy.py index 4b68288f7..0443108ed 100644 --- a/tripleoclient/v1/overcloud_deploy.py +++ b/tripleoclient/v1/overcloud_deploy.py @@ -736,18 +736,6 @@ class DeployOvercloud(command.Command): def setup_ephemeral_heat(self, parsed_args): self.log.info("Using ephemeral heat for stack operation") - # Skip trying to pull the images if they are set to the default - # as they can't be pulled since they are tagged as localhost. - # If the images are missing for some reason, podman will still pull - # them by default, and error appropriately if needed. - if (parsed_args.heat_container_api_image == - constants.DEFAULT_EPHEMERAL_HEAT_API_CONTAINER or - parsed_args.heat_container_engine_image == - constants.DEFAULT_EPHEMERAL_HEAT_ENGINE_CONTAINER): - skip_heat_pull = True - else: - skip_heat_pull = parsed_args.skip_heat_pull - self.heat_launcher = utils.get_heat_launcher( parsed_args.heat_type, api_container_image=parsed_args.heat_container_api_image, @@ -756,7 +744,7 @@ class DeployOvercloud(command.Command): 'heat-launcher'), use_tmp_dir=False, rm_heat=parsed_args.rm_heat, - skip_heat_pull=skip_heat_pull) + skip_heat_pull=parsed_args.skip_heat_pull) self.orchestration_client = utils.launch_heat(self.heat_launcher) self.clients.orchestration = self.orchestration_client