Browse Source

Check if container is running before doing an exec

(a partial backport limited only to discover_container_name)

It only consolidates the discover_container_name method in order to get
more chance to actually get a name.

Co-Authored-By: Cédric Jeanneret <cjeanner@redhat.com>
Closes-Bug: #1839559
Change-Id: If4d8c268218bf83abed877a699fc583fb55ccbed
(cherry picked from commit 983ab98f61)
changes/56/702456/2
Emilien Macchi 6 months ago
parent
commit
d66ba71100
1 changed files with 23 additions and 5 deletions
  1. +23
    -5
      paunch/runner.py

+ 23
- 5
paunch/runner.py View File

@@ -176,11 +176,29 @@ class DockerRunner(object):
'{{.Names}}'
]
(cmd_stdout, cmd_stderr, returncode) = self.execute(cmd, self.log)
if returncode != 0:
return container
names = cmd_stdout.split()
if names:
return names[0]
if returncode == 0:
names = cmd_stdout.split()
if names:
return names[0]
self.log.warning('Did not find container with "%s" - retrying without '
'config_id' % cmd)

cmd = [
self.docker_cmd,
'ps',
'-a',
'--filter',
'label=container_name=%s' % container,
'--format',
'{{.Names}}'
]
(cmd_stdout, cmd_stderr, returncode) = self.execute(cmd, self.log)
if returncode == 0:
names = cmd_stdout.split()
if names:
return names[0]

self.log.warning('Did not find container with "%s"' % cmd)
return container

def delete_missing_configs(self, config_ids):

Loading…
Cancel
Save