Skip to contentSkip to conversation

docker.py: always use --rm

PATCH Applied Paolo Bonzini 6 participants 10 messages Sep 17, 2020 – Sep 18, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 docker.py: always use --rm

Avoid that containers pile up.

---
 tests/docker/Makefile.include | 1 -
 tests/docker/docker.py        | 4 ++--
 2 files changed, 2 insertions(+), 3 deletions(-)
tests/docker/Makefile.include +0 -1
index 3daabaa2fd..75704268ff 100644
@@ -243,7 +243,6 @@ docker-run: docker-qemu-src
 		$(DOCKER_SCRIPT) run 					\
 			$(if $(NOUSER),,--run-as-current-user) 		\
 			--security-opt seccomp=unconfined		\
-			$(if $V,,--rm) 					\
 			$(if $(DEBUG),-ti,)				\
 			$(if $(NETWORK),$(if $(subst $(NETWORK),,1),--net=$(NETWORK)),--net=none) \
 			-e TARGET_LIST=$(subst $(SPACE),$(COMMA),$(TARGET_LIST))	\
tests/docker/docker.py +2 -2
index 356d7618f1..36b7868406 100755
@@ -377,7 +377,7 @@ class Docker(object):
             if self._command[0] == "podman":
                 cmd.insert(0, '--userns=keep-id')
 
-        ret = self._do_check(["run", "--label",
+        ret = self._do_check(["run", "--rm", "--label",
                              "com.qemu.instance.uuid=" + label] + cmd,
                              quiet=quiet)
         if not keep:
@@ -616,7 +616,7 @@ class CcCommand(SubCommand):
         if argv and argv[0] == "--":
             argv = argv[1:]
         cwd = os.getcwd()
-        cmd = ["--rm", "-w", cwd,
+        cmd = ["-w", cwd,
                "-v", "%s:%s:rw" % (cwd, cwd)]
         if args.paths:
             for p in args.paths:
Signature · 1 line
2.26.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Paolo Bonzini

Avoid that containers pile up.

---
 tests/docker/Makefile.include | 1 -
 tests/docker/docker.py        | 4 ++--
 2 files changed, 2 insertions(+), 3 deletions(-)
tests/docker/Makefile.include +0 -0
index 3daabaa2fd..75704268ff 100644

tests/docker/Makefile.include docker-run: docker-qemu-src · line 246

Quoted 4 lines
tests/docker/Makefile.include +0 -1
@@ -243,7 +243,6 @@ docker-run: docker-qemu-src
 		$(DOCKER_SCRIPT) run 					\
 			$(if $(NOUSER),,--run-as-current-user) 		\
 			--security-opt seccomp=unconfined		\
-			$(if $V,,--rm) 					\

I guess the intention was that if someone is running verbose they might want to get back into the container after a failure. This is certainly a pain for CI though, because running verbose is desirable but keeping around dead containers is not.

The DEBUG=1 option is likely a better general purpose debugging approach than relying on the dead container being left behind, so

Quoted 28 lines
tests/docker/Makefile.include +0 -0
 			$(if $(DEBUG),-ti,)				\
 			$(if $(NETWORK),$(if $(subst $(NETWORK),,1),--net=$(NETWORK)),--net=none) \
 			-e TARGET_LIST=$(subst $(SPACE),$(COMMA),$(TARGET_LIST))	\
tests/docker/docker.py +2 -2
index 356d7618f1..36b7868406 100755
@@ -377,7 +377,7 @@ class Docker(object):
             if self._command[0] == "podman":
                 cmd.insert(0, '--userns=keep-id')
 
-        ret = self._do_check(["run", "--label",
+        ret = self._do_check(["run", "--rm", "--label",
                              "com.qemu.instance.uuid=" + label] + cmd,
                              quiet=quiet)
         if not keep:
@@ -616,7 +616,7 @@ class CcCommand(SubCommand):
         if argv and argv[0] == "--":
             argv = argv[1:]
         cwd = os.getcwd()
-        cmd = ["--rm", "-w", cwd,
+        cmd = ["-w", cwd,
                "-v", "%s:%s:rw" % (cwd, cwd)]
         if args.paths:
             for p in args.paths:
Signature · 1 line
2.26.2

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#2 lore raw
Quoted 24 lines · Daniel P. Berrangé
Quoted 13 lines · Paolo Bonzini

Avoid that containers pile up.

---
 tests/docker/Makefile.include | 1 -
 tests/docker/docker.py        | 4 ++--
 2 files changed, 2 insertions(+), 3 deletions(-)
tests/docker/Makefile.include +0 -0
index 3daabaa2fd..75704268ff 100644

tests/docker/Makefile.include docker-run: docker-qemu-src · line 246

Quoted 4 lines
tests/docker/Makefile.include +0 -1
@@ -243,7 +243,6 @@ docker-run: docker-qemu-src
 		$(DOCKER_SCRIPT) run 					\
 			$(if $(NOUSER),,--run-as-current-user) 		\
 			--security-opt seccomp=unconfined		\
-			$(if $V,,--rm) 					\

I guess the intention was that if someone is running verbose they might want to get back into the container after a failure. This is certainly a pain for CI though, because running verbose is desirable but keeping around dead containers is not.

Quoted 4 lines

The DEBUG=1 option is likely a better general purpose debugging approach than relying on the dead container being left behind, so

Peter, can you apply this directly in order to unbreak Patchew?

Paolo

Quoted 34 lines
Quoted 30 lines
tests/docker/Makefile.include +0 -0
 			$(if $(DEBUG),-ti,)				\
 			$(if $(NETWORK),$(if $(subst $(NETWORK),,1),--net=$(NETWORK)),--net=none) \
 			-e TARGET_LIST=$(subst $(SPACE),$(COMMA),$(TARGET_LIST))	\
tests/docker/docker.py +2 -2
index 356d7618f1..36b7868406 100755
@@ -377,7 +377,7 @@ class Docker(object):
             if self._command[0] == "podman":
                 cmd.insert(0, '--userns=keep-id')
 
-        ret = self._do_check(["run", "--label",
+        ret = self._do_check(["run", "--rm", "--label",
                              "com.qemu.instance.uuid=" + label] + cmd,
                              quiet=quiet)
         if not keep:
@@ -616,7 +616,7 @@ class CcCommand(SubCommand):
         if argv and argv[0] == "--":
             argv = argv[1:]
         cwd = os.getcwd()
-        cmd = ["--rm", "-w", cwd,
+        cmd = ["-w", cwd,
                "-v", "%s:%s:rw" % (cwd, cwd)]
         if args.paths:
             for p in args.paths:
Signature · 1 line
2.26.2

Regards,
Daniel

#3 lore raw
In reply to Paolo Bonzini
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series failed the docker-quick@centos7 build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.

The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]

Acked-by on v1 1/1
#5 lore raw
In reply to Paolo Bonzini
Quoted 13 lines · Paolo Bonzini

Avoid that containers pile up.

---
 tests/docker/Makefile.include | 1 -
 tests/docker/docker.py        | 4 ++--
 2 files changed, 2 insertions(+), 3 deletions(-)
tests/docker/Makefile.include +0 -0
index 3daabaa2fd..75704268ff 100644

tests/docker/Makefile.include docker-run: docker-qemu-src · line 246

Quoted 5 lines
tests/docker/Makefile.include +0 -1
@@ -243,7 +243,6 @@ docker-run: docker-qemu-src
 		$(DOCKER_SCRIPT) run 					\
 			$(if $(NOUSER),,--run-as-current-user) 		\
 			--security-opt seccomp=unconfined		\
-			$(if $V,,--rm) 					\
 			$(if $(DEBUG),-ti,)				\

Alternatively:

-                       $(if $V,,--rm)
-                       $(if $(DEBUG),-ti,)
+                       $(if $(DEBUG),-ti,--rm)

Anyhow:

Quoted 25 lines
tests/docker/Makefile.include +0 -0
 			$(if $(NETWORK),$(if $(subst $(NETWORK),,1),--net=$(NETWORK)),--net=none) \
 			-e TARGET_LIST=$(subst $(SPACE),$(COMMA),$(TARGET_LIST))	\
tests/docker/docker.py +2 -2
index 356d7618f1..36b7868406 100755
@@ -377,7 +377,7 @@ class Docker(object):
             if self._command[0] == "podman":
                 cmd.insert(0, '--userns=keep-id')
 
-        ret = self._do_check(["run", "--label",
+        ret = self._do_check(["run", "--rm", "--label",
                              "com.qemu.instance.uuid=" + label] + cmd,
                              quiet=quiet)
         if not keep:
@@ -616,7 +616,7 @@ class CcCommand(SubCommand):
         if argv and argv[0] == "--":
             argv = argv[1:]
         cwd = os.getcwd()
-        cmd = ["--rm", "-w", cwd,
+        cmd = ["-w", cwd,
                "-v", "%s:%s:rw" % (cwd, cwd)]
         if args.paths:
             for p in args.paths:
#6 lore raw
Quoted 22 lines · Philippe Mathieu-Daudé
Quoted 13 lines · Paolo Bonzini

Avoid that containers pile up.

---
 tests/docker/Makefile.include | 1 -
 tests/docker/docker.py        | 4 ++--
 2 files changed, 2 insertions(+), 3 deletions(-)
tests/docker/Makefile.include +0 -0
index 3daabaa2fd..75704268ff 100644

tests/docker/Makefile.include docker-run: docker-qemu-src · line 246

Quoted 5 lines
tests/docker/Makefile.include +0 -1
@@ -243,7 +243,6 @@ docker-run: docker-qemu-src
 		$(DOCKER_SCRIPT) run 					\
 			$(if $(NOUSER),,--run-as-current-user) 		\
 			--security-opt seccomp=unconfined		\
-			$(if $V,,--rm) 					\
 			$(if $(DEBUG),-ti,)				\

Alternatively:

Review

Quoted 3 lines
(quoted diff) +1 -2
-                       $(if $V,,--rm)
-                       $(if $(DEBUG),-ti,)
+                       $(if $(DEBUG),-ti,--rm)

Surely that should b:

  $(if $(DEBUG),-ti --rm,)

I think being able to keep the container around is useful for debug, I have no problem with changing the behaviour for V=1.

Quoted 29 lines

Anyhow:

Quoted 25 lines
tests/docker/Makefile.include +0 -0
 			$(if $(NETWORK),$(if $(subst $(NETWORK),,1),--net=$(NETWORK)),--net=none) \
 			-e TARGET_LIST=$(subst $(SPACE),$(COMMA),$(TARGET_LIST))	\
tests/docker/docker.py +2 -2
index 356d7618f1..36b7868406 100755
@@ -377,7 +377,7 @@ class Docker(object):
             if self._command[0] == "podman":
                 cmd.insert(0, '--userns=keep-id')
 
-        ret = self._do_check(["run", "--label",
+        ret = self._do_check(["run", "--rm", "--label",
                              "com.qemu.instance.uuid=" + label] + cmd,
                              quiet=quiet)
         if not keep:
@@ -616,7 +616,7 @@ class CcCommand(SubCommand):
         if argv and argv[0] == "--":
             argv = argv[1:]
         cwd = os.getcwd()
-        cmd = ["--rm", "-w", cwd,
+        cmd = ["-w", cwd,
                "-v", "%s:%s:rw" % (cwd, cwd)]
         if args.paths:
             for p in args.paths:
Signature · 1 line
Alex Bennée
#7 lore raw

Il gio 17 set 2020, 18:53 Alex Bennée <[email protected]> ha scritto:

Quoted 30 lines
Quoted 10 lines · Philippe Mathieu-Daudé

Review

Quoted 9 lines · Paolo Bonzini

Avoid that containers pile up.

---
 tests/docker/Makefile.include | 1 -
 tests/docker/docker.py        | 4 ++--
 2 files changed, 2 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/tests/docker/Makefile.include

Quoted 12 lines

tests/docker/Makefile.include docker-run: docker-qemu-src · line 246

Quoted 9 lines

index 3daabaa2fd..75704268ff 100644

tests/docker/Makefile.include +0 -1
@@ -243,7 +243,6 @@ docker-run: docker-qemu-src
             $(DOCKER_SCRIPT) run                                    \
                     $(if $(NOUSER),,--run-as-current-user)          \
                     --security-opt seccomp=unconfined               \
-                    $(if $V,,--rm)                                  \
                     $(if $(DEBUG),-ti,)                             \

Alternatively:

Review

Quoted 3 lines
(quoted diff) +1 -2
-                       $(if $V,,--rm)
-                       $(if $(DEBUG),-ti,)
+                       $(if $(DEBUG),-ti,--rm)
Quoted 7 lines

Surely that should b:

  $(if $(DEBUG),-ti --rm,)

I think being able to keep the container around is useful for debug, I have no problem with changing the behaviour for V=1.

You probably mean $(if $(DEBUG),-ti,--rm) but that would not work because the patch adds --rm unconditionally in docker.py. But $(DEBUG) gives you a shell to run the test from, so I don't think skipping --rm is useful even in the $(DEBUG) case.

Paolo

Quoted 1 line
#8 lore raw

Got it.

Quoted 50 lines · On Thu, 17 Sep 2020, 17:58 Paolo Bonzini, <[email protected]> wrote:

Il gio 17 set 2020, 18:53 Alex Bennée <[email protected]> ha scritto:

Quoted 30 lines
Quoted 10 lines · Philippe Mathieu-Daudé

Review

Quoted 9 lines · Paolo Bonzini

Avoid that containers pile up.

---
 tests/docker/Makefile.include | 1 -
 tests/docker/docker.py        | 4 ++--
 2 files changed, 2 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/tests/docker/Makefile.include

Quoted 12 lines

tests/docker/Makefile.include docker-run: docker-qemu-src · line 246

Quoted 9 lines

index 3daabaa2fd..75704268ff 100644

tests/docker/Makefile.include +0 -1
@@ -243,7 +243,6 @@ docker-run: docker-qemu-src
             $(DOCKER_SCRIPT) run                                    \
                     $(if $(NOUSER),,--run-as-current-user)          \
                     --security-opt seccomp=unconfined               \
-                    $(if $V,,--rm)                                  \
                     $(if $(DEBUG),-ti,)                             \

Alternatively:

Review

Quoted 3 lines
(quoted diff) +1 -2
-                       $(if $V,,--rm)
-                       $(if $(DEBUG),-ti,)
+                       $(if $(DEBUG),-ti,--rm)
Quoted 7 lines

Surely that should b:

  $(if $(DEBUG),-ti --rm,)

I think being able to keep the container around is useful for debug, I have no problem with changing the behaviour for V=1.

You probably mean $(if $(DEBUG),-ti,--rm) but that would not work because the patch adds --rm unconditionally in docker.py. But $(DEBUG) gives you a shell to run the test from, so I don't think skipping --rm is useful even in the $(DEBUG) case.

Paolo

Quoted 1 line