Skip to content

fix(transfer): resolve container paths against declared bind mounts - #260

Open
ndeloof wants to merge 1 commit into
containerd:mainfrom
ndeloof:transfer-resolve-bind-mounts
Open

fix(transfer): resolve container paths against declared bind mounts#260
ndeloof wants to merge 1 commit into
containerd:mainfrom
ndeloof:transfer-resolve-bind-mounts

Conversation

@ndeloof

@ndeloof ndeloof commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

The container-FS transferrer anchors both directions at the bundle's rootfs. That directory backs only the paths no mount covers: where the runtime spec declares a bind mount, the container's mount namespace has the source mounted over the destination, so the rootfs entry underneath is shadowed.

Importing to such a path therefore produces a file the container never sees, and exporting from one archives whatever the rootfs happens to hold rather than the mounted content. Neither reports an error.

resolveMountRoot reads the bundle spec and maps a container-view path onto the directory backing it, preferring the longest matching bind destination so a nested mount wins over its parent. Both directions go through it.

A bundle with no readable or parseable config.json resolves to the rootfs, so callers supplying no mount information are unaffected.

Tests

TestReadPathImportLandsInBindSource and TestWritePathExportReadsBindSource assert the observable effect rather than the mapping: the import must land in the mount source and not in the shadowed rootfs entry, and the export must carry the mounted bytes where the rootfs holds different content at the same name. Both fail on the previous behaviour.

TestResolveMountRootSelectsLongestDestination covers nesting, an uncovered path, and a sibling whose name merely shares the prefix.

The container-FS transferrer anchored both directions at the bundle's rootfs.
That directory backs only the paths no mount covers: where the runtime spec
declares a bind mount, the container's mount namespace has the source mounted
over the destination, so the rootfs entry underneath is shadowed.

Importing to such a path therefore produced a file the container never sees,
and exporting from one archived whatever the rootfs happened to hold instead
of the mounted content. Neither reported an error.

resolveMountRoot reads the bundle spec and maps a container-view path onto the
directory backing it, preferring the longest matching bind destination so a
nested mount wins over its parent. Both directions go through it, keeping the
import and export views consistent with the container's own.

A bundle with no readable or parseable config.json resolves to the rootfs, so
callers that supply no mount information are unaffected.

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
Copilot AI review requested due to automatic review settings July 29, 2026 15:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants