From 28b87d9bf14ff84af700ae889b657173bb4bd2ba Mon Sep 17 00:00:00 2001 From: Bruno Goncalves Date: Mar 05 2018 10:03:01 +0000 Subject: remove container if can't install Ansible dependencies --- diff --git a/inventory/standard-inventory-docker b/inventory/standard-inventory-docker index b8d625d..cb1df71 100755 --- a/inventory/standard-inventory-docker +++ b/inventory/standard-inventory-docker @@ -114,6 +114,9 @@ def host(image, docker_extra_args): try: subprocess.check_call(install, stdout=sys.stderr.fileno()) except subprocess.CalledProcessError as ex: + # Could not install necessary packages to run the tests. + # Need to stop and remove the container. + subprocess.call(["/usr/bin/docker", "rm", "-f", name ], stdout=null) raise RuntimeError("Could not install Ansible dependencies in launched container") # Directory to place artifacts @@ -175,7 +178,6 @@ def host(image, docker_extra_args): # Kill the container with open(log, "w") as f: subprocess.call(["/usr/bin/docker", "logs", name ], stdout=f.fileno()) - subprocess.call(["/usr/bin/docker", "kill", name ], stdout=null.fileno()) subprocess.call(["/usr/bin/docker", "rm", "-f", name ], stdout=null) shutil.rmtree(directory)