Fix discovering container names
(a partial backport limited to action 'run')
Make discover_container_name returning None, if the ps command failed
or returned nothing useful.
* For 'run', if no container name has been discovered, use its
predictable (fixed) container service name.
Related-Bug: #1839929
Co-Authored-By: Cédric Jeanneret <cjeanner@redhat.com>
Change-Id: I8a495d2c98617bb5edbe13ccf737d6c630eea7ad
Signed-off-by: Bogdan Dobrelya <bdobreli@redhat.com>
(cherry picked from commit 3dcbe5e68c
)
This commit is contained in:
parent
d66ba71100
commit
f8ede6b362
|
@ -55,11 +55,13 @@ class ComposeV1Builder(object):
|
||||||
'Skipping existing container: %s' % container)
|
'Skipping existing container: %s' % container)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
c_name = self.runner.discover_container_name(
|
||||||
|
container, self.config_id) or container
|
||||||
cmd = [
|
cmd = [
|
||||||
self.runner.docker_cmd,
|
self.runner.docker_cmd,
|
||||||
'run',
|
'run',
|
||||||
'--name',
|
'--name',
|
||||||
self.runner.unique_container_name(container)
|
c_name
|
||||||
]
|
]
|
||||||
self.label_arguments(cmd, container)
|
self.label_arguments(cmd, container)
|
||||||
self.docker_run_args(cmd, container)
|
self.docker_run_args(cmd, container)
|
||||||
|
|
|
@ -199,7 +199,6 @@ class DockerRunner(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:
|
||||||
|
|
|
@ -226,7 +226,7 @@ four-12345678 four
|
||||||
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')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ four-12345678 four
|
||||||
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')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue