Skip to content

Give a pod's containers what a container with its own machine has - #885

Open
MayCXC wants to merge 10 commits into
apple:mainfrom
MayCXC:pod-parity
Open

Give a pod's containers what a container with its own machine has#885
MayCXC wants to merge 10 commits into
apple:mainfrom
MayCXC:pod-parity

Conversation

@MayCXC

@MayCXC MayCXC commented Aug 27, 2026

Copy link
Copy Markdown

Summary

Five independent fixes for capabilities a container loses the moment it is placed in a pod.

Copying files in and out. Copying a file between the host and a container is reachable only for a container in a machine of its own; the same container placed in a pod has no way to be copied into or out of, so a tool that offers cp loses it the moment a container joins a pod. What the transfer needs is the machine, the path the container's filesystem sits at in the guest, and a vsock port, and only the path differs between the two cases. It moves to a type that takes those, which both a standalone container and a pod's containers hand it.

A writable layer. A container with a machine of its own can be given a block device to write into, with its image mounted read-only beneath, so the image is left as it is and every write lands in the layer. The same container placed in a pod has nowhere to be given one. The layer is attached with the container's other block devices, mounted in the guest as the upper layer of an overlay over the image, dropped from the mounts the runtime spec carries, and unmounted with the container. A pod's containers take one whether they were placed before the machine booted or hotplugged into it afterwards.

The machine it asked for. A container with a machine of its own is given the size it asked for plus the guest agent's, so a container that asks for a gibibyte has a gibibyte and the agent runs beside it. A pod hands its size to the machine as it stands, so the agent comes out of what the pod asked for and its containers are left with less: a pod given twelve gibibytes reports eleven and a half. The pod's size and the agent's are added the same way now, and what a pod was given is what its containers have.

Giving a container's place back. Stopping a container tears down what it was running and keeps its place: the name still answers for it, and placing another container under it is refused. Removal is the separate act the runtime specification names for giving the place up, taken once the container has stopped, so a name can run again in a machine that outlives what it last ran. https://github.com/kubernetes/cri-api/blob/master/pkg/apis/runtime/v1/api.proto

A wrong copyright line. GuestFileTransfer.swift carried the sibling repository's line, so the license header check found no header it recognized.

Dependency and Merge Order

This targets stock apple/containerization:main and depends on #872, which in turn depends on #863. Merge order: #863, then #872, then this. The head carries both prerequisites' commits because all three target stock main; after they merge, this branch takes current main and its remaining diff is the five fixes.

Motivation and Context

Discussion: #879. Nothing here touches the swap work in #877, and the five commits are independent of one another, so any can be dropped without the others.

Testing

  • make containerization and make check clean.
  • swift test: 593 tests in 81 suites passed.
  • make integration: the cp round trip is covered against a running pod, including that a file copied into one container reaches that container alone.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

MayCXC added 10 commits August 27, 2026 20:43
The reaper that runs at a concurrency of one deletes everything in the
test directory except the unpacked rootfs it means to preserve. It held
that rootfs path as FileManager reports it, under /var, and compared it
against the entries of contentsOfDirectory, which reports them under
/private/var, so the preserved path never matched any entry and the
rootfs was deleted along with the per-test files. The unpack coordinator
still held it as unpacked, so the next test opened a rootfs that was no
longer there and failed with a missing file error.

Resolve both sides with resolvingSymlinksInPathWithPrivate, which exists
for this difference between the two views of the same directory.
Tests guarded for Linux are compiled out on macOS, so `make test` reports
success without having run them, and nothing says so. The target that
does run them is not mentioned anywhere outside the makefile.
The default kernel the tests fetch had drifted from the one users run.
container installs kata 3.28.0 and its 6.18.15 kernel, while these tests
fetched 3.17.0, so the suite exercised a guest with a different feature
set to the one it is meant to represent. Nested runtimes are the visible
case: 3.17.0 was built without nf_tables, so a docker daemon inside a
container fails there and works on what ships.

Kata moved from xz to zstd between those releases, so the archive is no
longer named for its compression and tar is left to recognise it rather
than being told, which also holds if the format changes again.
A test's rootfs clones, init block, and writable layers land in a
directory the runner creates for it and deletes when it finishes, so a
test holds disk only while it runs at any concurrency. The run-shared
directory holds the unpacked images every bootstrap clones from, and is
removed when the run ends.
A container's storage is its rootfs, an optional writable layer, and its
mounts; a machine's is its containers' plus the volumes they share. One
generic shape describes both the Mount values a machine is configured
with and the AttachedFilesystem values it reports once attached, so
converting between the two is a map over the structure and the roles
cannot drift between configuration and attachment.

Device addresses are allocated walking the same sorted order the devices
are created in, on both backends. Consumers read roles instead of list
positions: the spec builders take a container's mounts without prefix
arithmetic, pod volumes mount by name, and a cloud-hypervisor volume's
virtiofsd is held by a machine-lifetime reference alongside its
containers' reference counts.
Copying a file between the host and a container is reachable only for a
container in a machine of its own; the same container placed in a pod has
no way to be copied into or out of, so a tool that offers `cp` loses it the
moment a container joins a pod.

What the transfer needs is the machine, the path the container's filesystem
sits at in the guest, and a vsock port, and only the path differs between
the two cases. It moves to a type that takes those, which both a standalone
container and a pod's containers hand it.

The round trip is covered against a running pod, including that a file
copied into one container reaches that container alone.
A container with a machine of its own is given the size it asked for plus
the guest agent's, so a container that asks for a gibibyte has a gibibyte
and the agent runs beside it. A pod hands its size to the machine as it
stands, so the agent comes out of what the pod asked for and its containers
are left with less: a pod given twelve gibibytes reports eleven and a half.

The pod's size and the agent's are added the same way, and what a pod was
given is what its containers have.
A container with a machine of its own can be given a block device to write
into, with its image mounted read-only beneath, so the image is left as it
is and every write lands in the layer. The same container placed in a pod
has nowhere to be given one.

The layer is attached with the container's other block devices, mounted in
the guest as the upper layer of an overlay over the image, dropped from the
mounts the runtime spec carries, and unmounted with the container. A pod's
containers take one whether they were placed before the machine booted or
hotplugged into it afterwards.
The file carried the sibling repository's copyright line, so the license
header check found no header it recognized.
Stopping a container tears down what it was running and keeps its place:
the name still answers for it, and placing another container under it is
refused. Removal is the separate act the runtime specification names for
giving the place up, taken once the container has stopped, so a name can
run again in a machine that outlives what it last ran.
https://github.com/kubernetes/cri-api/blob/master/pkg/apis/runtime/v1/api.proto
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.

1 participant