[v2] deb-dl-dir: Avoid hanging mounts on failed download

Message ID 20241024100946.214428-1-amikan@ilbers.de
State Accepted, archived
Headers show
Series [v2] deb-dl-dir: Avoid hanging mounts on failed download | expand

Commit Message

Anton Mikanovich Oct. 24, 2024, 10:09 a.m. UTC
If apt-get fails during debsrc_download execution, one mount will be
left behind. If ISAR_FAIL_ON_CLEANUP is set to 1, an additional error
will be observed:

| Err:1 http://ftp.de.debian.org/debian bookworm/main rtmpdump 2.4+20151223.gitfa8646d.1-2 (dsc)
|   Could not connect to ftp.de.debian.org:80 (141.76.2.4), connection timed out
| Err:2 http://ftp.de.debian.org/debian bookworm/main rtmpdump 2.4+20151223.gitfa8646d.1-2 (tar)
|   Unable to connect to ftp.de.debian.org:80:
| Err:3 http://ftp.de.debian.org/debian bookworm/main rtmpdump 2.4+20151223.gitfa8646d.1-2 (diff)
|   Unable to connect to ftp.de.debian.org:80:
| E: Failed to fetch http://ftp.de.debian.org/debian/pool/main/r/rtmpdump/rtmpdump_2.4%2b20151223.gitfa8646d.1-2.dsc  Could not connect to ftp.de.debian.org:80 (141.76.2.4), connection timed out
| E: Failed to fetch http://ftp.de.debian.org/debian/pool/main/r/rtmpdump/rtmpdump_2.4%2b20151223.gitfa8646d.1.orig.tar.gz  Unable to connect to ftp.de.debian.org:80:
| E: Failed to fetch http://ftp.de.debian.org/debian/pool/main/r/rtmpdump/rtmpdump_2.4%2b20151223.gitfa8646d.1-2.debian.tar.xz  Unable to connect to ftp.de.debian.org:80:
| E: Failed to fetch some archives.
| WARNING: exit code 100 from a shell command.
| DEBUG: Executing shell function rootfs_do_umounts
| DEBUG: Shell function rootfs_do_umounts finished
| DEBUG: Python function do_rootfs_postprocess finished
NOTE: recipe isar-image-ci-1.0-r0: task do_rootfs_postprocess: Failed
NOTE: Tasks Summary: Attempted 699 tasks of which 391 didn't need to be rerun and 1 failed.
ERROR: build/tmp/work/debian-bookworm-armhf/isar-image-ci-qemuarm/1.0-r0/rootfs/deb-src left mounted

Protect mounting with a trap for cleanup in case of failure.

Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
---
 meta/classes/deb-dl-dir.bbclass | 3 +++
 1 file changed, 3 insertions(+)

Comments

Uladzimir Bely Oct. 24, 2024, 10:41 a.m. UTC | #1
On Thu, 2024-10-24 at 13:09 +0300, Anton Mikanovich wrote:
> If apt-get fails during debsrc_download execution, one mount will be
> left behind. If ISAR_FAIL_ON_CLEANUP is set to 1, an additional error
> will be observed:
> 
> > Err:1 http://ftp.de.debian.org/debian bookworm/main rtmpdump
> > 2.4+20151223.gitfa8646d.1-2 (dsc)
> >   Could not connect to ftp.de.debian.org:80 (141.76.2.4),
> > connection timed out
> > Err:2 http://ftp.de.debian.org/debian bookworm/main rtmpdump
> > 2.4+20151223.gitfa8646d.1-2 (tar)
> >   Unable to connect to ftp.de.debian.org:80:
> > Err:3 http://ftp.de.debian.org/debian bookworm/main rtmpdump
> > 2.4+20151223.gitfa8646d.1-2 (diff)
> >   Unable to connect to ftp.de.debian.org:80:
> > E: Failed to fetch
> > http://ftp.de.debian.org/debian/pool/main/r/rtmpdump/rtmpdump_2.4%2b20151223.gitfa8646d.1-2.dsc
> >   Could not connect to ftp.de.debian.org:80 (141.76.2.4),
> > connection timed out
> > E: Failed to fetch
> > http://ftp.de.debian.org/debian/pool/main/r/rtmpdump/rtmpdump_2.4%2b20151223.gitfa8646d.1.orig.tar.gz
> >   Unable to connect to ftp.de.debian.org:80:
> > E: Failed to fetch
> > http://ftp.de.debian.org/debian/pool/main/r/rtmpdump/rtmpdump_2.4%2b20151223.gitfa8646d.1-2.debian.tar.xz
> >   Unable to connect to ftp.de.debian.org:80:
> > E: Failed to fetch some archives.
> > WARNING: exit code 100 from a shell command.
> > DEBUG: Executing shell function rootfs_do_umounts
> > DEBUG: Shell function rootfs_do_umounts finished
> > DEBUG: Python function do_rootfs_postprocess finished
> NOTE: recipe isar-image-ci-1.0-r0: task do_rootfs_postprocess: Failed
> NOTE: Tasks Summary: Attempted 699 tasks of which 391 didn't need to
> be rerun and 1 failed.
> ERROR: build/tmp/work/debian-bookworm-armhf/isar-image-ci-
> qemuarm/1.0-r0/rootfs/deb-src left mounted
> 
> Protect mounting with a trap for cleanup in case of failure.
> 
> Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
> ---
>  meta/classes/deb-dl-dir.bbclass | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/meta/classes/deb-dl-dir.bbclass b/meta/classes/deb-dl-
> dir.bbclass
> index 55e56c50..7ebd057e 100644
> --- a/meta/classes/deb-dl-dir.bbclass
> +++ b/meta/classes/deb-dl-dir.bbclass
> @@ -48,6 +48,9 @@ debsrc_download() {
>  
>      debsrc_do_mounts "${rootfs}"
>  
> +    trap 'exit 1' INT HUP QUIT TERM ALRM USR1
> +    trap 'debsrc_undo_mounts "${rootfs}"' EXIT
> +
>      ( flock 9
>      set -e
>      printenv | grep -q BB_VERBOSE_LOGS && set -x
> -- 
> 2.34.1
> 

Since patch v2 is technically a v1 with updated commit message, already
well-tested in CI, we would like to merge it soon (e.g. 2024-10-25), if
there are no objections.
Uladzimir Bely Oct. 25, 2024, 1:57 p.m. UTC | #2
On Thu, 2024-10-24 at 13:09 +0300, Anton Mikanovich wrote:
> If apt-get fails during debsrc_download execution, one mount will be
> left behind. If ISAR_FAIL_ON_CLEANUP is set to 1, an additional error
> will be observed:
> 
> > Err:1 http://ftp.de.debian.org/debian bookworm/main rtmpdump
> > 2.4+20151223.gitfa8646d.1-2 (dsc)
> >   Could not connect to ftp.de.debian.org:80 (141.76.2.4),
> > connection timed out
> > Err:2 http://ftp.de.debian.org/debian bookworm/main rtmpdump
> > 2.4+20151223.gitfa8646d.1-2 (tar)
> >   Unable to connect to ftp.de.debian.org:80:
> > Err:3 http://ftp.de.debian.org/debian bookworm/main rtmpdump
> > 2.4+20151223.gitfa8646d.1-2 (diff)
> >   Unable to connect to ftp.de.debian.org:80:
> > E: Failed to fetch
> > http://ftp.de.debian.org/debian/pool/main/r/rtmpdump/rtmpdump_2.4%2b20151223.gitfa8646d.1-2.dsc
> >   Could not connect to ftp.de.debian.org:80 (141.76.2.4),
> > connection timed out
> > E: Failed to fetch
> > http://ftp.de.debian.org/debian/pool/main/r/rtmpdump/rtmpdump_2.4%2b20151223.gitfa8646d.1.orig.tar.gz
> >   Unable to connect to ftp.de.debian.org:80:
> > E: Failed to fetch
> > http://ftp.de.debian.org/debian/pool/main/r/rtmpdump/rtmpdump_2.4%2b20151223.gitfa8646d.1-2.debian.tar.xz
> >   Unable to connect to ftp.de.debian.org:80:
> > E: Failed to fetch some archives.
> > WARNING: exit code 100 from a shell command.
> > DEBUG: Executing shell function rootfs_do_umounts
> > DEBUG: Shell function rootfs_do_umounts finished
> > DEBUG: Python function do_rootfs_postprocess finished
> NOTE: recipe isar-image-ci-1.0-r0: task do_rootfs_postprocess: Failed
> NOTE: Tasks Summary: Attempted 699 tasks of which 391 didn't need to
> be rerun and 1 failed.
> ERROR: build/tmp/work/debian-bookworm-armhf/isar-image-ci-
> qemuarm/1.0-r0/rootfs/deb-src left mounted
> 
> Protect mounting with a trap for cleanup in case of failure.
> 
> Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
> ---
>  meta/classes/deb-dl-dir.bbclass | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/meta/classes/deb-dl-dir.bbclass b/meta/classes/deb-dl-
> dir.bbclass
> index 55e56c50..7ebd057e 100644
> --- a/meta/classes/deb-dl-dir.bbclass
> +++ b/meta/classes/deb-dl-dir.bbclass
> @@ -48,6 +48,9 @@ debsrc_download() {
>  
>      debsrc_do_mounts "${rootfs}"
>  
> +    trap 'exit 1' INT HUP QUIT TERM ALRM USR1
> +    trap 'debsrc_undo_mounts "${rootfs}"' EXIT
> +
>      ( flock 9
>      set -e
>      printenv | grep -q BB_VERBOSE_LOGS && set -x
> -- 
> 2.34.1
> 

Applied to next.

Patch

diff --git a/meta/classes/deb-dl-dir.bbclass b/meta/classes/deb-dl-dir.bbclass
index 55e56c50..7ebd057e 100644
--- a/meta/classes/deb-dl-dir.bbclass
+++ b/meta/classes/deb-dl-dir.bbclass
@@ -48,6 +48,9 @@  debsrc_download() {
 
     debsrc_do_mounts "${rootfs}"
 
+    trap 'exit 1' INT HUP QUIT TERM ALRM USR1
+    trap 'debsrc_undo_mounts "${rootfs}"' EXIT
+
     ( flock 9
     set -e
     printenv | grep -q BB_VERBOSE_LOGS && set -x