Repository navigation
feat: containerd is a rootstock plugin, orchd-rootstock-containerd - #79
Merged
Merged
Conversation
The long-hung containerd runtime (#7) comes back as a contract-1 plugin in Zig. One foreground run per tree drives containerd's gRPC API itself: pull through Transfer, read the image through Content, prepare the snapshot, create the container and its task, wait, and on SIGTERM kill, wait and delete task, container and snapshot. gRPC rides on nghttp2, compiled from its release by our own build.zig, with the protobuf for the dozen messages written by hand. The container's stdout and stderr come back through FIFOs, so they land in orchd's logs. runc's no_pivot_root is opt-in (ORCHD_CONTAINERD_NO_PIVOT_ROOT=1) for initramfs roots such as an applz VM.
zig 0.17 unpacks dependencies into zig-pkg/ beside build.zig.zon, and the plugin's .gitignore did not say so.
adiled
added a commit
that referenced
this pull request
Nov 9, 2026
On teardown the keeper sends SIGTERM to the tree's **process group**, but it waited only for its **direct child**, the `/bin/sh -c start` shell. The shell dies at once, while the process that actually does the work may still be cleaning up. So the keeper and `fell` returned early, leaving the cleanup orphaned. Found by #79's CI: `fell` returned in 0.2 s while the containerd run leaf was still deleting its task, so the "nothing left" check saw the task. The keeper now waits until the whole group is gone (`kill(-pgid, 0)` fails), still within the stop timeout, after which it SIGKILLs the group as before. **Repro** (scratch, macOS): a tree of `sh -c 'trap "sleep 1; touch cleaned; exit 0" TERM; while :; do sleep 0.1; done'; true`. The trailing `; true` keeps the shell from exec'ing the child. | | keeper exits after TERM | cleanup done when it exits | |---|---|---| | main | 0.26 s | no (finished later, orphaned) | | this | 1.14 s | yes, nothing left |
Five seconds for the task to stop on SIGTERM, then SIGKILL and two more, so killing, deleting and removing finish within the keeper's default ten.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #7. The containerd runtime returns as a contract-1 plugin in Zig, with the PR's design: one foreground
runper tree that drives containerd's gRPC API itself.The run leaf
Transfer, which also unpacks into overlayfs.Images.Get, thenContent.Readfor index → manifest → config; fold the layers' diff_ids into the chainID.Snapshots.Preparewith that chainID as parent.Containers.Createwith an OCI spec: host network namespace, masked and read-only paths, the service's limits.Tasks.Createwith FIFOs for stdout/stderr, thenStartandWait.New since the Rust PR
no_pivot_rootis opt-in withORCHD_CONTAINERD_NO_PIVOT_ROOT=1. It's needed for initramfs roots (an applz VM) but is the weaker choice on a normal host, where the PR forced it.checkcalls containerd'sVersionRPC rather than just looking for the socket.The wire, built here
build.zig(26 C files, its header translated withaddTranslateC). No foreign build script runs, and it links statically into the musl Linux binaries.grpc-status/grpc-messagefrom trailers, thecontainerd-namespaceheader. Calls take an interrupt flag and a timeout..protofiles.Tests
grpc-statuserrors, interrupt and timeout.no_pivot_root):checkreturned the version;runpulled alpine and started it (ctrshowed RUNNING); the container's output and a host bind mount came through; SIGTERM exited 143 and left no task, container or snapshot.containerd.yml, Ubuntu runner, amd64,pivot_root):orchd grow --rootstock containerdon orchdi,ctrshows it RUNNING, the output reaches the keeper's log,fellleaves nothing behind.Note: an early commit on this branch accidentally included nghttp2's unpacked source under
zig-pkg/. It's removed and ignored, and this PR is squash-merged, so main never carries it.