← Back to issue list

Can't prime symlink in resulting oci

View original Github issue

Metadata

Project
rockcraft
Number
#208
Type
issue
State
closed
Author
gboutry
Labels
—
Created
Updated
Closed

Current evaluation

Symlinked subdirs were dropped when building OCI layers because os.walk() does not follow symlinks. Fixed by merged PR #211 (commit 1783fa2a, "oci: fix handling of symlink subdirs") in rockcraft/layers.py.

Resolution: closed resolved

Reason: Commit 1783fa2a (PR #211) added logic in rockcraft/layers.py to add each subdirectory that is a symlink to the layer archive result, since os.walk() never enters them. This preserves primed links such as /usr/share/perl/5.30 in the final OCI image.

Evaluated by: mr-cal-bot

No scores available.

Issue body

I'm trying to build a rock with apache2 webserver. I'm hitting a problem where I'm trying to get a symlink into the final image but I can't. I'm creating multiple symlinks in the same scriptlet, and the link using `ln` doesn't show up in the final image. ```yaml override-prime: | craftctl default chroot $CRAFT_PRIME ln -srf /usr/share/perl/5.30.0/ /usr/share/perl/5.30 # Enable default mpm mod a2enmod -m -q mpm_event ``` `a2enmod` basically creates a symlink in `/etc/apache2/mods-enabled`. And these symlinks appear in the final image. Inside the LXD container: ```bash $ rockcraft -v prime --shell-after root@rockcraft-keystone-55075201:~/project# ls -alh ../prime/etc/apache2/mods-enabled/mpm* lrwxrwxrwx 1 root root 32 Mar 6 11:35 ../prime/etc/apache2/mods-enabled/mpm_event.conf -> ../mods-available/mpm_event.conf lrwxrwxrwx 1 root root 32 Mar 6 11:35 ../prime/etc/apache2/mods-enabled/mpm_event.load -> ../mods-available/mpm_event.load root@rockcraft-keystone-55075201:~/project# ls -alh ../prime/usr/share/perl/ lrwxrwxrwx 1 root root 6 Oct 5 10:27 5.30 -> 5.30.0 drwxr-xr-x 53 root root 128 Mar 6 11:56 5.30.0 ``` After packing the rock and pushing into the docker daemon with skopeo: ```bash $ docker run --rm -it keystone:yoga bash root@aa3e33b7a43b:/# ls -alh /etc/apache2/mods-enabled/mpm* lrwxrwxrwx 1 root root 32 Mar 6 11:35 /etc/apache2/mods-enabled/mpm_event.conf -> ../mods-available/mpm_event.conf lrwxrwxrwx 1 root root 32 Mar 6 11:35 /etc/apache2/mods-enabled/mpm_event.load -> ../mods-available/mpm_event.load root@aa3e33b7a43b:/# ls -alh /usr/share/perl/ drwxr-xr-x 53 root root 4.0K Mar 6 11:56 5.30.0 ``` The link created with `ln` is missing from the docker image. Am I missing something to get the symlink in the docker image ?

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Symlinked subdirs were dropped when building OCI layers because os.walk() does not follow symlinks. Fixed by merged PR #211 (commit 1783fa2a, "oci: fix handling of symlink subdirs") in rockcraft/layers.py.
stealth/space-bunny-alpha — closed resolved Fixed by merged PR #211 (commit 1783fa2a): OCI archive creation now includes symlinked subdirectories, preserving primed links such as /usr/share/perl/5.30.
qwen/qwen3.6-35b-a3b — — Closed after root cause was identified: os.walk skips symlinks during OCI image creation. Author proposed a patch to include symlinked subdirectories, resolving the problem.
qwen/qwen3.6-35b-a3b — — Closed without a fix after the author identified os.walk skipping symlinks in rockcraft/oci.py during OCI packing. A patch to preserve symlinked directories was proposed but never merged.
qwen/qwen3.6-35b-a3b — — Closed after root cause identified; a patch to follow symlinks in rockcraft/oci.py was proposed to fix the priming failure.
qwen3.6-35b-a3b-mtp-q6 — — Closed without resolution. User identified that os.walk in rockcraft/oci.py skips symlinks during OCI image creation and proposed a patch, but it was not merged.

Update history

No update history recorded yet.

Related work

  • Likely Fixed By: canonical/rockcraft#211 (confidence 95%)

    PR #211 merged as commit 1783fa2a adding symlinked subdirs to the OCI layer archive.

  • Related To: canonical/rockcraft#200 (confidence 60%)

    Earlier commit 3f43e30e (PR #200) fixed usrmerge subdir handling in the same code area.

  • Related To: canonical/rockcraft#195 (confidence 55%)

    LXD 5.0/overlay-packages breakage reporter hit while trying workarounds for this issue.

Related issues

Issue Project State Summary Similarity
#211 oci: fix handling of symlink subdirs rockcraft merged Merged PR #211 in commit 1783fa2a, fixing OCI archive creation to include symlinked subdirectories and resolving #208.
70%