Skip to content

Let a service manager run as a container's init - #866

Open
MayCXC wants to merge 4 commits into
apple:mainfrom
MayCXC:systemd-mode
Open

Let a service manager run as a container's init#866
MayCXC wants to merge 4 commits into
apple:mainfrom
MayCXC:systemd-mode

Conversation

@MayCXC

@MayCXC MayCXC commented Aug 27, 2026

Copy link
Copy Markdown

Summary

An image built around a service manager expects to own the runtime state it keeps, and finds nowhere to write it: a container gets its image's filesystem and the mounts a single process needs, so the manager cannot start and takes the container down with it.

Give it somewhere to write, which is what podman gives such a container, and take the same paths to mean one is being asked for. The container says which of the three it wants: never, whenever the process it starts is a service manager, or whatever it starts. Never is the default, as it is for the runtimes that create cgroups themselves.

A mount the caller supplied for one of those places is left as they asked for it, and a pod's containers ask the same way.

Dependency and Merge Order

This targets stock apple/containerization:main and depends on #863. Please merge #863 first.

The head carries #863's three commits as prerequisites, because both PRs target stock main. After #863 merges this branch can take current main, leaving only the systemd-mode change and its test.

The dependency is real rather than incidental: a systemd container needs nf_tables in the guest, and #863 is what makes the suite run against the kernel release the shipped tool installs rather than an older one built without it.

Motivation and Context

The journal directory here is /var/log/journal, which is where systemd-journald writes persistent logs, with volatile logs going to /run/log/journal:
https://www.freedesktop.org/software/systemd/man/latest/journald.conf.html

Worth noting for reviewers comparing against other runtimes: nerdctl's list names /var/lib/journal, which journald does not consult, so a container given that one has a tmpfs nothing writes to. podman uses /var/log/journal. This follows podman.

Testing

  • swift build and make check clean.
  • swift test: 603 tests in 83 suites passed.
  • Integration: container systemd boots a systemd image as init and asserts both that PID 1 is systemd and that it reaches a running or degraded state, rather than dying at start.

Type of Change

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

MayCXC added 4 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.
An image built around a service manager expects to own the runtime state it
keeps, and finds nowhere to write it: a container gets its image's
filesystem and the mounts a single process needs, so the manager cannot
start and takes the container down with it.

Give it somewhere to write, which is what nerdctl and podman give such a
container, and take the same paths to mean one is being asked for. The
container says which of the three it wants: never, whenever the process it
starts is a service manager, or whatever it starts. Never is the default,
as it is for the runtimes that create cgroups themselves.

A mount the caller supplied for one of those places is left as they asked
for it, and a pod's containers ask the same way.
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