Merge "Fix discovering container names"

This commit is contained in:
Zuul 2019-09-24 01:00:01 +00:00 committed by Gerrit Code Review
commit 9ed99000d3
3 changed files with 10 additions and 8 deletions

View File

@ -78,17 +78,20 @@ class BaseBuilder(object):
container)
continue
c_name = self.runner.discover_container_name(
container, self.config_id) or container
cmd = [
self.runner.cont_cmd,
start_cmd,
'--name',
container_name
c_name
]
self.label_arguments(cmd, container)
validations_passed = self.container_run_args(cmd,
container,
container_name)
self.log.debug("Start container {} as {}.".format(container,
c_name))
validations_passed = self.container_run_args(
cmd, container, c_name)
elif action == 'exec':
# for exec, the first argument is the fixed named container
# used when running the command into the running container.
@ -102,7 +105,7 @@ class BaseBuilder(object):
# Before running the exec, we want to make sure the container
# is running.
# https://bugs.launchpad.net/bugs/1839559
if not self.runner.container_running(c_name):
if not c_name or not self.runner.container_running(c_name):
msg = ('Failing to apply action exec for '
'container: %s' % container)
raise RuntimeError(msg)

View File

@ -171,7 +171,6 @@ class BaseRunner(object):
return names[0]
self.log.warning('Did not find container with "%s"' % cmd)
return container
def delete_missing_configs(self, config_ids):
if not config_ids:

View File

@ -142,7 +142,7 @@ class TestBaseRunner(base.TestCase):
self.mock_execute(popen, '', '', 0)
self.assertEqual(
'one',
None,
self.runner.discover_container_name('one', 'foo')
)
@ -151,7 +151,7 @@ class TestBaseRunner(base.TestCase):
self.mock_execute(popen, '', 'ouch', 1)
self.assertEqual(
'one',
None,
self.runner.discover_container_name('one', 'foo')
)