From: Cleber Rosa <crosa@redhat.com>
To: "Alex Bennée" <alex.bennee@linaro.org>
Cc: "Fam Zheng" <fam@euphon.net>,
peter.maydell@linaro.org, qemu-arm@nongnu.org,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
qemu-devel@nongnu.org
Subject: Re: [PATCH v2 04/16] tests/docker: reduce scary warnings from failed inspect
Date: Mon, 23 Sep 2019 16:51:15 -0400 [thread overview]
Message-ID: <20190923205115.GE6528@dhcp-17-179.bos.redhat.com> (raw)
In-Reply-To: <20190919171015.12681-5-alex.bennee@linaro.org>
On Thu, Sep 19, 2019 at 06:10:03PM +0100, Alex Bennée wrote:
> There is a race here in the clean-up code so lets just accept that
> sometimes the active task we just looked up might have finished before
> we got to inspect it.
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> tests/docker/docker.py | 32 ++++++++++++++++++--------------
> 1 file changed, 18 insertions(+), 14 deletions(-)
>
> diff --git a/tests/docker/docker.py b/tests/docker/docker.py
> index 29613afd489..4dca6006d2f 100755
> --- a/tests/docker/docker.py
> +++ b/tests/docker/docker.py
> @@ -235,20 +235,24 @@ class Docker(object):
> if not only_active:
> cmd.append("-a")
> 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])
> + try:
> + 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])
Both podman and docker seem to handle "rm -f $INSTANCE" well, which
would by itself consolidate the two commands in one and minimize the
race condition.
For unexisting containers, and no other errors, podman will return "1
if one of the specified containers did not exist, and no other
failure", as per its man page. I couldn't find any guarantee that
docker will also return 1 on a similar situation, but that's what
I've experienced too:
$ docker rm -f CONTAINER_IS_NOW_FONE
Error response from daemon: No such container: CONTAINER_IS_NOW_GONE
$ echo $?
1
Maybe waiving exit status 1 and nothing else would do the trick here
and not hide other real problems?
- Cleber.
> + except subprocess.CalledProcessError:
> + # i likely finished running before we got here
> + pass
>
> def clean(self):
> self._do_kill_instances(False, False)
> --
> 2.20.1
>
>
next prev parent reply other threads:[~2019-09-23 21:04 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-19 17:09 [PATCH v2 00/16] testing/next (docker/podman, tcg, build fixes) Alex Bennée
2019-09-19 17:10 ` [PATCH v2 01/16] tests/docker: add sanitizers back to clang build Alex Bennée
2019-09-19 17:10 ` [PATCH v2 02/16] tests/docker: fix DOCKER_PARTIAL_IMAGES Alex Bennée
2019-09-23 19:46 ` Cleber Rosa
2019-09-19 17:10 ` [PATCH v2 03/16] tests/docker: remove python2.7 from docker9-mxe Alex Bennée
2019-09-23 19:49 ` Cleber Rosa
2019-09-23 19:55 ` John Snow
2019-09-19 17:10 ` [PATCH v2 04/16] tests/docker: reduce scary warnings from failed inspect Alex Bennée
2019-09-23 20:51 ` Cleber Rosa [this message]
2019-09-23 23:00 ` Alex Bennée
2019-09-19 17:10 ` [PATCH v2 05/16] podman: fix command invocation Alex Bennée
2019-09-23 18:47 ` Cleber Rosa
2019-09-19 17:10 ` [PATCH v2 06/16] target/ppc: fix signal delivery for ppc64abi32 Alex Bennée
2019-09-20 19:27 ` Laurent Vivier
2019-09-19 17:10 ` [PATCH v2 07/16] tests/tcg: clean-up some comments after the de-tangling Alex Bennée
2019-09-19 17:10 ` [PATCH v2 08/16] tests/tcg: re-enable linux-test for ppc64abi32 Alex Bennée
2019-09-19 22:00 ` Richard Henderson
2019-09-19 17:10 ` [PATCH v2 09/16] tests/tcg: add float_madds test to multiarch Alex Bennée
2019-09-19 22:07 ` Richard Henderson
2019-09-19 17:10 ` [PATCH v2 10/16] tests/tcg: add generic version of float_convs Alex Bennée
2019-09-19 22:09 ` Richard Henderson
2019-09-20 9:29 ` Alex Bennée
2019-09-20 10:15 ` Alex Bennée
2019-09-20 22:09 ` Richard Henderson
2019-09-19 17:10 ` [PATCH v2 11/16] tests/tcg: add simple record/replay smoke test for aarch64 Alex Bennée
2019-09-19 17:10 ` [PATCH v2 12/16] tests/docker: Add fedora-win10sdk-cross image Alex Bennée
2019-09-19 17:10 ` [PATCH v2 13/16] .shippable.yml: Build WHPX enabled binaries Alex Bennée
2019-09-19 17:10 ` [PATCH v2 14/16] configure: preserve PKG_CONFIG for subdir builds Alex Bennée
2019-09-19 22:12 ` Richard Henderson
2019-09-19 17:10 ` [PATCH v2 15/16] docs/devel: add "check-tcg" to testing.rst Alex Bennée
2019-09-19 17:10 ` [PATCH v2 16/16] Makefile: fix-up qemu-ga.8 paths to take in-src builds into account Alex Bennée
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190923205115.GE6528@dhcp-17-179.bos.redhat.com \
--to=crosa@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=fam@euphon.net \
--cc=peter.maydell@linaro.org \
--cc=philmd@redhat.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).