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) container)
continue continue
c_name = self.runner.discover_container_name(
container, self.config_id) or container
cmd = [ cmd = [
self.runner.cont_cmd, self.runner.cont_cmd,
start_cmd, start_cmd,
'--name', '--name',
container_name c_name
] ]
self.label_arguments(cmd, container) self.label_arguments(cmd, container)
validations_passed = self.container_run_args(cmd, self.log.debug("Start container {} as {}.".format(container,
container, c_name))
container_name) validations_passed = self.container_run_args(
cmd, container, c_name)
elif action == 'exec': elif action == 'exec':
# for exec, the first argument is the fixed named container # for exec, the first argument is the fixed named container
# used when running the command into the running 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 # Before running the exec, we want to make sure the container
# is running. # is running.
# https://bugs.launchpad.net/bugs/1839559 # 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 ' msg = ('Failing to apply action exec for '
'container: %s' % container) 'container: %s' % container)
raise RuntimeError(msg) raise RuntimeError(msg)

View File

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

View File

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