← Back to issue list

Keep overlayfs mounted when running with --debug and something fails

View original Github issue

Metadata

Project
imagecraft
Number
#148
Type
issue
State
open
Author
toabctl
Labels
Type: Bug
Created
Updated
Closed
—

Current evaluation

Debug shells start after a failed overlay's fuse-overlayfs mount is already unmounted; the requested behavior remains unresolved and may require craft-parts support.

Suggested action: keep open

Reason: The report includes a reproducible command and logs showing that overlayfs is unmounted before the debug shell opens. craft-parts' LayerMount.__exit__ currently unmounts unconditionally, while lengau's comment confirms maintainer awareness but leaves ownership/design unresolved; this is a valid debugability bug with moderate cross-component complexity.

Evaluated by: mr-cal-bot

Impact: 42 Quick Win: 14 Complexity: 57 Confidence: 91 Actionability: 78

Issue body

### Bug Description Currently the overlayfs gets unmounted before dropping into the debug shell if the overlay-script part fails. But that makes debugging a lot harder given that the environment changed compared to the state were it failed. ### To Reproduce Eg. running: ``` CRAFT_BUILD_ENVIRONMENT=multipass imagecraft --verbosity debug pack --debug ``` this will result in output like: ``` 2025-05-19 09:08:41.466 Overlaying chimg 2025-05-19 09:08:41.467 execute action chimg:Action(part_name='chimg', step=Step.OVERLAY, action_type=ActionType.RUN, reason=None, project_vars=None, properties=ActionProperties(changed_files=None, changed_dirs=None)) 2025-05-19 09:08:41.467 mount overlayfs on /root/overlay/overlay 2025-05-19 09:08:41.467 fuse-overlayfs mountpoint='/root/overlay/overlay', args=('-olowerdir=/root/parts/rootfs/layer:/root/overlay/packages:/root/bare_base_layer,upperdir=/root/parts/chimg/layer,workdir=/root/overlay/work',)unknown argument ignored: lazytime 2025-05-19 09:08:41.512 Executing PosixPath('/tmp/tmphp409_az/scriptlet.sh') 2025-05-19 09:08:41.513 :: + exit 1 2025-05-19 09:08:41.514 unmount overlayfs from /root/overlay/overlay 2025-05-19 09:08:41.514 umount mountpoint='/root/overlay/overlay', args=() 2025-05-19 09:08:41.516 'overlay-script' in part 'chimg' failed with code 1. 2025-05-19 09:08:41.516 Launching shell on build environment... 2025-05-19 09:08:41.516 Emitter: Pausing control of the terminal imagecraft-ubuntu-minimal-amd64-236227516 ../project# ``` So `/root/overlay/overlay` is no longer mounted so I can't easily rerun/debug the command from the `overlay-script` section. ### Environment * ubuntu 25.04 on amd64 * imagecraft from latest/edge channel ### imagecraft.yaml ```shell name: ubuntu-minimal version: "0.1" base: bare build-base: ubuntu@22.04 platforms: amd64: volumes: pc: schema: gpt structure: - name: efi type: C12A7328-F81F-11D2-BA4B-00A0C93EC93B filesystem: vfat role: system-boot filesystem-label: UEFI size: 256M - name: rootfs type: 0FC63DAF-8483-4772-8E79-3D69D8477DE4 filesystem: ext4 filesystem-label: writable role: system-data size: 5G parts: # build a simple rootfs rootfs: plugin: nil build-packages: - "mmdebstrap" overlay-script: | mmdebstrap --arch $CRAFT_ARCH_BUILD_FOR \ --mode=sudo \ --format=dir \ --include=ca-certificates,ubuntu-pro-client \ --variant=minbase \ --include=apt \ jammy \ $CRAFT_OVERLAY/ mkdir $CRAFT_OVERLAY/boot/efi # add packages using chroot and apt to have maintainer scripts properly run chimg: plugin: dump source: . source-type: local after: [rootfs] overlay-script: | # THIS FAILS SO I WANT TO HAVE THE OVERLAY MOUNTED WHEN DROPPING INTO THE DEBUG SHELL exit 1 # fix fstab and organize content to the partition fstab: plugin: nil after: [chimg] overlay-script: | cat << EOF > $CRAFT_OVERLAY/etc/fstab LABEL=writable / ext4 discard,errors=remount-ro 0 1 LABEL=UEFI /boot/efi vfat umask=0077 0 1 EOF mv $CRAFT_OVERLAY/* $CRAFT_VOLUME_PC_ROOTFS_OVERLAY/ ``` ### Relevant log output ```shell 2025-05-19 09:08:41.466 Overlaying chimg 2025-05-19 09:08:41.467 execute action chimg:Action(part_name='chimg', step=Step.OVERLAY, action_type=ActionType.RUN, reason=None, project_vars=None, properties=ActionProperties(changed_files=None, changed_dirs=None)) 2025-05-19 09:08:41.467 mount overlayfs on /root/overlay/overlay 2025-05-19 09:08:41.467 fuse-overlayfs mountpoint='/root/overlay/overlay', args=('-olowerdir=/root/parts/rootfs/layer:/root/overlay/packages:/root/bare_base_layer,upperdir=/root/parts/chimg/layer,workdir=/root/overlay/work',)unknown argument ignored: lazytime 2025-05-19 09:08:41.512 Executing PosixPath('/tmp/tmphp409_az/scriptlet.sh') 2025-05-19 09:08:41.513 :: + exit 1 2025-05-19 09:08:41.514 unmount overlayfs from /root/overlay/overlay 2025-05-19 09:08:41.514 umount mountpoint='/root/overlay/overlay', args=() 2025-05-19 09:08:41.516 'overlay-script' in part 'chimg' failed with code 1. 2025-05-19 09:08:41.516 Launching shell on build environment... 2025-05-19 09:08:41.516 Emitter: Pausing control of the terminal imagecraft-ubuntu-minimal-amd64-236227516 ../project# ```

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha
Impact: 42
Quick Win: 14
Complexity: 57
Confidence: 91
Actionability: 78
keep open Debug shells start after a failed overlay's fuse-overlayfs mount is already unmounted; the requested behavior remains unresolved and may require craft-parts support.
qwen/qwen3.6-35b-a3b
Impact: 30
Quick Win: 13
Complexity: 40
Confidence: 70
Actionability: 70
keep open Overlayfs is unmounted before dropping into debug shell when overlay-script fails, making debugging harder. Issue is open, has a clear reproducer, and was discussed by maintainers.
qwen/qwen3.8-27b
Impact: 45
Quick Win: 27
Staleness: 55
Complexity: 40
Confidence: 70
Support Request: 10
keep open imagecraft unmounts overlayfs before dropping into the --debug shell when an overlay-script fails, making it hard to inspect the failed state. Workaround is manual fuse-overlayfs remount. A maintainer (lengau) asked whether craft-parts should handle this, but no fix has landed.
qwen/qwen3.6-35b-a3b
Staleness: 78
Complexity: 35
Confidence: 70
Support Request: 10
keep open Bug requesting overlayfs stay mounted when --debug triggers after a script failure. Currently inactive for over a year with no maintainer response.
qwen3.6-35b-a3b-mtp-q6
Staleness: 75
Complexity: 35
Confidence: 60
Support Request: 10
keep open Requests keeping overlayfs mounted when --debug is active and a script fails, to aid debugging. Currently unmounts before dropping to shell. Inactive for over a year with maintainer discussion about upstream resolution in craft-parts.
qwen3.6-35b-a3b-mtp-q6
Staleness: 85
Complexity: 45
Confidence: 60
Support Request: 10
needs triage Overlayfs is unmounted before dropping into a debug shell when an overlay-script fails, hindering debugging. Issue is untriaged and inactive for over 10 months.

Update history

No update history recorded yet.

Related issues

No related issues found above the similarity threshold.