Fix return results on cmd failure and error msgs
Return an empty list if container_names fails since that result is used
in a loop for many places.
Add error messages for better observability as well.
Change-Id: Ia79cbf74faa4d8190d2280757403fd2e5b67fbe0
Co-authored-by: Alex Schultz <aschultz@redhat.com>
Signed-off-by: Bogdan Dobrelya <bdobreli@redhat.com>
(cherry picked from commit a838a69c4f
)
This commit is contained in:
parent
f294ce2b11
commit
66487257e7
|
@ -36,6 +36,9 @@ class DockerRunner(object):
|
||||||
subproc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
|
subproc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE)
|
stderr=subprocess.PIPE)
|
||||||
cmd_stdout, cmd_stderr = subproc.communicate()
|
cmd_stdout, cmd_stderr = subproc.communicate()
|
||||||
|
if subproc.returncode != 0:
|
||||||
|
log.error('Error executing %s: returned %s' % (cmd,
|
||||||
|
subproc.returncode))
|
||||||
log.debug(cmd_stdout)
|
log.debug(cmd_stdout)
|
||||||
log.debug(cmd_stderr)
|
log.debug(cmd_stderr)
|
||||||
return (cmd_stdout.decode('utf-8'),
|
return (cmd_stdout.decode('utf-8'),
|
||||||
|
@ -100,7 +103,7 @@ class DockerRunner(object):
|
||||||
))
|
))
|
||||||
cmd_stdout, cmd_stderr, returncode = self.execute(cmd, self.log)
|
cmd_stdout, cmd_stderr, returncode = self.execute(cmd, self.log)
|
||||||
if returncode != 0:
|
if returncode != 0:
|
||||||
return
|
return []
|
||||||
result = []
|
result = []
|
||||||
for line in cmd_stdout.split("\n"):
|
for line in cmd_stdout.split("\n"):
|
||||||
if line:
|
if line:
|
||||||
|
|
Loading…
Reference in New Issue