diff --git a/paunch/builder/base.py b/paunch/builder/base.py index c0f30fb..44ea7a7 100644 --- a/paunch/builder/base.py +++ b/paunch/builder/base.py @@ -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) diff --git a/paunch/runner.py b/paunch/runner.py index d735c58..cd0b3fa 100644 --- a/paunch/runner.py +++ b/paunch/runner.py @@ -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: diff --git a/paunch/tests/test_runner.py b/paunch/tests/test_runner.py index e0862d4..5c35333 100644 --- a/paunch/tests/test_runner.py +++ b/paunch/tests/test_runner.py @@ -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') )