Merge "Skip Heat pod container image pull for default ephemeral heat images"

This commit is contained in:
Zuul 2021-12-03 17:30:21 +00:00 committed by Gerrit Code Review
commit 3c9d68c80f
3 changed files with 29 additions and 14 deletions

View File

@ -38,6 +38,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
@ -467,7 +469,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

View File

@ -20,6 +20,7 @@ import subprocess
import time
from unittest import mock
from tripleoclient import constants
from tripleoclient import heat_launcher
from tripleoclient.exceptions import HeatPodMessageQueueException
from tripleoclient.tests import base
@ -68,11 +69,24 @@ class TestHeatPodLauncher(base.TestCase):
launcher._fetch_container_image()
self.check_output.assert_not_called()
# 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.check_output.assert_called_with(['sudo', 'podman', 'pull',
mock.ANY])
# 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()

View File

@ -603,18 +603,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,
@ -623,7 +611,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