Browse Source

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)
changes/57/702457/2
Bogdan Dobrelya 5 months ago
parent
commit
f8ede6b362
3 changed files with 5 additions and 4 deletions
  1. +3
    -1
      paunch/builder/compose1.py
  2. +0
    -1
      paunch/runner.py
  3. +2
    -2
      paunch/tests/test_runner.py

+ 3
- 1
paunch/builder/compose1.py View File

@@ -55,11 +55,13 @@ class ComposeV1Builder(object):
'Skipping existing container: %s' % container)
continue

c_name = self.runner.discover_container_name(
container, self.config_id) or container
cmd = [
self.runner.docker_cmd,
'run',
'--name',
self.runner.unique_container_name(container)
c_name
]
self.label_arguments(cmd, container)
self.docker_run_args(cmd, container)

+ 0
- 1
paunch/runner.py View File

@@ -199,7 +199,6 @@ class DockerRunner(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:

+ 2
- 2
paunch/tests/test_runner.py View File

@@ -226,7 +226,7 @@ four-12345678 four
self.mock_execute(popen, '', '', 0)

self.assertEqual(
'one',
None,
self.runner.discover_container_name('one', 'foo')
)

@@ -235,7 +235,7 @@ four-12345678 four
self.mock_execute(popen, '', 'ouch', 1)

self.assertEqual(
'one',
None,
self.runner.discover_container_name('one', 'foo')
)


Loading…
Cancel
Save