Skip to content

rechunk recipe (Chunkah) crashes with "Argument list too long" on base images chunked with the older rechunker (e.g. Bluefin) #236

Description

@Danathar

I've been making my own little utility to help people create their own images (Atomic Image Builder). My utility bundles the latest version of this template into its code for use. When I tried to use Chunkah, it failed for a rather interesting reason.

Apologies if I got any of this wrong. I had to ask Claude a bunch of questions about WHY this occurred, so hopefully it didn't take me down a mirage rabbit hole! Some of the investigation rests on answers it gave me. A lot of this is me talking, and some of it is Claude, edited by me. All that being said, the fix worked when I patched it on my side in my utility.

The rechunk recipe in the bundled Justfile (Justfile#L129-L147) fails immediately, before Chunkah even starts, when run against a base image that was chunked upstream with the older rechunker. The error:

podman: Argument list too long
error: recipe `rechunk` failed with exit code 126

My utility tried to build on Bluefin GNOME, which is chunked upstream with the older hhd-dev/rechunk tool. That tool writes a huge package-manifest label onto the image: a blob listing every installed package and its version. When I tested my utility against Silverblue and Kinoite, it didn't fail; so they don't carry that label. I haven't tried it against Aurora yet, but I'd bet it would work, because Aurora switched to Chunkah for its own builds, and Chunkah doesn't work the same way. It doesn't leave that metadata behind.

In the Justfile:

export CHUNKAH_CONFIG_STR=$(podman inspect "${target_image}")
podman run --rm --mount=type=image,src="${target_image}",target=/chunkah \
-e CHUNKAH_CONFIG_STR quay.io/coreos/chunkah:latest \
...

The podman inspect and the variable assignment both succeed; bash has no problem holding it. The problem is the next line: when podman run -e CHUNKAH_CONFIG_STR ... tries to spawn the podman process, the kernel has to copy the whole environment into the new process, and no single environment variable can exceed 128 KiB. When the target image is Bluefin, podman inspect against it produces ~307 KiB of output, so CHUNKAH_CONFIG_STR ends up that big too (mostly that package-manifest label), and the kernel refuses to create the process at all. podman never gets to run, which is why the error comes from bash.

Claude recommended passing the data via a file instead of an environment variable, which avoids the problem entirely:

Chunkah documents a second, equivalent way to provide the exact same data: a file, via --config <path>, instead of an environment variable (README, "Customizing the OCI image config and annotations"). This patch would be for the rechunk recipe in the Justfile:

-    export CHUNKAH_CONFIG_STR=$(podman inspect "${target_image}")
-    podman run --rm --mount=type=image,src="${target_image}",target=/chunkah \
-    -e CHUNKAH_CONFIG_STR quay.io/coreos/chunkah:latest \
+    CHUNKAH_CONFIG_FILE=$(mktemp)
+    podman inspect "${target_image}" > "${CHUNKAH_CONFIG_FILE}"
+    podman run --rm --mount=type=image,src="${target_image}",target=/chunkah \
+    -v "${CHUNKAH_CONFIG_FILE}:/chunkah-config.json:ro,Z" quay.io/coreos/chunkah:latest \
     build \
     --verbose \
     --compressed \
     --max-layers 128 \
     --prune /sysroot/ \
     --label ostree.commit- --label ostree.final-diffid- \
+    --config /chunkah-config.json \
     --tag "${target_image}:${tag}" | podman load
+    rm -f "${CHUNKAH_CONFIG_FILE}"

Apologies for the long explanation, I do that to explain it to myself as well! ;) Put simply: that variable can't hold the manifest, so you need to pass that info via a file.

The fix was verified when I used it: the unpatched recipe reproduces the exact error against a real ghcr.io/ublue-os/bluefin:stable pull, and the patched one completes a full Chunkah build.

About the Z in the mount: the relabel flag is needed when running locally on SELinux-enforcing hosts (any Fedora/Atomic machine). Since the Justfile is also the local-build path, that covers a lot of this template's audience. On the Ubuntu GitHub runners it's not needed (AppArmour instead of SELinux?), so it's harmless to include everywhere probably.

If you agree with this fix, I can submit a PR for it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions