From 704b6870ba339345dc1de5d698df38f5467e4dd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Jeanneret?= Date: Wed, 16 Jan 2019 14:03:16 +0100 Subject: [PATCH] Reuse the container in case we have a temporary podman failure The "retry" patch[1] didn't take care of the existing container. This patch intends to allow to reuse the container in case it has failed, in order to avoid an error when the container is already existing. [1] https://review.openstack.org/#/c/614639/ Change-Id: I5c7258c8687582f56b59ed410c0cc8f6ba4c2d4f Context: https://github.com/containers/libpod/issues/1844 Related-Bug: #1811383 --- docker/docker-puppet.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docker/docker-puppet.py b/docker/docker-puppet.py index 24a47f0174..c68f683fd8 100755 --- a/docker/docker-puppet.py +++ b/docker/docker-puppet.py @@ -456,8 +456,12 @@ def mp_puppet_config(*args): count = 0 log.debug('Running %s command: %s' % (container_cli, ' '.join(dcmd))) while count < 3: + if count == 0: + cmd = dcmd + else: + cmd = [cli_cmd, 'start', '-a', uname] count += 1 - subproc = subprocess.Popen(dcmd, stdout=subprocess.PIPE, + subproc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env) cmd_stdout, cmd_stderr = subproc.communicate() retval = subproc.returncode @@ -465,14 +469,14 @@ def mp_puppet_config(*args): # and 2 for success and resource changes. Other numbers are failures if retval in [0,2]: if cmd_stdout: - log.debug('%s run succeeded: %s' % (dcmd, cmd_stdout)) + log.debug('%s run succeeded: %s' % (cmd, cmd_stdout)) if cmd_stderr: log.warning(cmd_stderr) # only delete successful runs, for debugging rm_container(uname) break time.sleep(3) - log.warning('%s run failed after %s attempt(s): %s' % (dcmd, + log.warning('%s run failed after %s attempt(s): %s' % (cmd, cmd_stderr, count)) log.warning('Retrying running container: %s' % config_volume)