[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 12/28] tests/docker: reduce scary warnings by cleaning up clean up
From: |
Alex Bennée |
Subject: |
[PULL 12/28] tests/docker: reduce scary warnings by cleaning up clean up |
Date: |
Thu, 26 Sep 2019 19:35:37 +0100 |
There was in the clean-up code caused by attempting to inspect images
which finished before we got there. Clean up the clean up code by:
- only track the one instance at a time
- use --filter for docker ps instead of doing it by hand
- just call docker rm -f to be done with it
- use uuid.uuid4() for a random uid
Signed-off-by: Alex Bennée <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index 29613afd48..3112892fdf 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -215,7 +215,7 @@ class Docker(object):
""" Running Docker commands """
def __init__(self):
self._command = _guess_engine_command()
- self._instances = []
+ self._instance = None
atexit.register(self._kill_instances)
signal.signal(signal.SIGTERM, self._kill_instances)
signal.signal(signal.SIGHUP, self._kill_instances)
@@ -234,21 +234,19 @@ class Docker(object):
cmd = ["ps", "-q"]
if not only_active:
cmd.append("-a")
+
+ filter = "--filter=label=com.qemu.instance.uuid"
+ if only_known:
+ if self._instance:
+ filter += "=%s" % (self._instance)
+ else:
+ # no point trying to kill, we finished
+ return
+
+ print("filter=%s" % (filter))
+ cmd.append(filter)
for i in self._output(cmd).split():
- resp = self._output(["inspect", i])
- labels = json.loads(resp)[0]["Config"]["Labels"]
- active = json.loads(resp)[0]["State"]["Running"]
- if not labels:
- continue
- instance_uuid = labels.get("com.qemu.instance.uuid", None)
- if not instance_uuid:
- continue
- if only_known and instance_uuid not in self._instances:
- continue
- print("Terminating", i)
- if active:
- self._do(["kill", i])
- self._do(["rm", i])
+ self._do(["rm", "-f", i])
def clean(self):
self._do_kill_instances(False, False)
@@ -325,9 +323,9 @@ class Docker(object):
return checksum == _text_checksum(_dockerfile_preprocess(dockerfile))
def run(self, cmd, keep, quiet, as_user=False):
- label = uuid.uuid1().hex
+ label = uuid.uuid4().hex
if not keep:
- self._instances.append(label)
+ self._instance = label
if as_user:
uid = os.getuid()
@@ -340,7 +338,7 @@ class Docker(object):
"com.qemu.instance.uuid=" + label] + cmd,
quiet=quiet)
if not keep:
- self._instances.remove(label)
+ self._instance = None
return ret
def command(self, cmd, argv, quiet):
--
2.20.1
- [PULL 04/28] target/alpha: Handle SWCR_MAP_DMZ earlier, (continued)
- [PULL 04/28] target/alpha: Handle SWCR_MAP_DMZ earlier, Alex Bennée, 2019/09/26
- [PULL 06/28] target/alpha: Mask IOV exception with INV for user-only, Alex Bennée, 2019/09/26
- [PULL 09/28] tests/docker: add sanitizers back to clang build, Alex Bennée, 2019/09/26
- [PULL 08/28] target/ppc: fix signal delivery for ppc64abi32, Alex Bennée, 2019/09/26
- [PULL 10/28] tests/docker: fix DOCKER_PARTIAL_IMAGES, Alex Bennée, 2019/09/26
- [PULL 07/28] target/alpha: Tidy helper_fp_exc_raise_s, Alex Bennée, 2019/09/26
- [PULL 11/28] tests/docker: remove python2.7 from debian9-mxe, Alex Bennée, 2019/09/26
- [PULL 13/28] podman: fix command invocation, Alex Bennée, 2019/09/26
- [PULL 14/28] tests/tcg: clean-up some comments after the de-tangling, Alex Bennée, 2019/09/26
- [PULL 24/28] docker: remove 'deprecated' image definitions, Alex Bennée, 2019/09/26
- [PULL 12/28] tests/docker: reduce scary warnings by cleaning up clean up,
Alex Bennée <=
- [PULL 17/28] tests/tcg: add generic version of float_convs, Alex Bennée, 2019/09/26
- [PULL 26/28] docker: remove unused debian-sid, Alex Bennée, 2019/09/26
- [PULL 19/28] configure: preserve PKG_CONFIG for subdir builds, Alex Bennée, 2019/09/26
- [PULL 22/28] docker: remove debian8-mxe definitions, Alex Bennée, 2019/09/26
- [PULL 25/28] docker: remove unused debian-ports, Alex Bennée, 2019/09/26
- [PULL 27/28] docker: move tests from python2 to python3, Alex Bennée, 2019/09/26
- [PULL 18/28] tests/tcg: add simple record/replay smoke test for aarch64, Alex Bennée, 2019/09/26
- [PULL 23/28] docker: remove unused debian8 partial image, Alex Bennée, 2019/09/26
- [PULL 28/28] tests/docker: remove debian-powerpc-user-cross, Alex Bennée, 2019/09/26
- [PULL 20/28] docs/devel: add "check-tcg" to testing.rst, Alex Bennée, 2019/09/26