Skip to content

Commit 45b03bd

Browse files
authored
fix: declare container identity for systemd nodes (#59)
Signed-off-by: Tianyu Zhou <albert.zty@antgroup.com>
1 parent 03a1a98 commit 45b03bd

6 files changed

Lines changed: 36 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,26 @@ jobs:
132132
IMAGE_TAG="${GITHUB_SHA}" \
133133
RUNTIME_PROFILE=rrt
134134
135+
- name: Verify systemd container identity in the image
136+
run: |
137+
docker image inspect "akernel-ci/all-in-one:${GITHUB_SHA}" \
138+
--format '{{json .Config.Env}}' | \
139+
python -c 'import json, sys; assert "container=oci" in json.load(sys.stdin)'
140+
135141
- name: Start standalone AKernel
136142
run: |
137143
IMAGE="akernel-ci/all-in-one:${GITHUB_SHA}" \
138144
AKERNEL_NAT_BACKEND=iptables \
139145
./deploy/standalone/start.sh
140146
147+
- name: Verify PID 1 detects its container
148+
run: |
149+
docker exec akernel-node bash -euo pipefail -c '
150+
tr "\0" "\n" < /proc/1/environ | grep -x "container=oci"
151+
test "$(cat /run/systemd/container)" = oci
152+
systemd-detect-virt --container
153+
'
154+
141155
- name: Run SDK end-to-end examples
142156
run: |
143157
gateway_ip="$(docker inspect \

AGENTS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,13 @@ Use [`deploy/README.md`](./deploy/README.md) as the deployment entry point.
183183
AKernel supports standalone, existing Kubernetes clusters via Helm, and
184184
Terraform-based cloud provisioning.
185185

186+
The all-in-one image and node launchers declare lowercase `container=oci`
187+
for PID 1 systemd. Preserve this in the final image, Helm node environment,
188+
and standalone launcher: without container detection, privileged systemd
189+
shutdown can remount shared host filesystems read-only. See
190+
[`deploy/README.md#systemd-container-identity`](./deploy/README.md#systemd-container-identity)
191+
for deployment implications.
192+
186193
Aliyun's aggregate Pod PID budget is configurable independently of the
187194
per-sandbox limit; see `deploy/terraform/aliyun/README.md#pod-pid-budget`.
188195

builder/node.Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@ COPY ./src/distill-fs/ ./
233233
RUN cargo build --locked --release --bin distill_fs
234234

235235
FROM ${AKERNEL_NODE_BASE_IMAGE}
236+
# Let PID 1 systemd avoid remounting shared host filesystems during shutdown.
237+
ENV container=oci
238+
236239
ARG AKERNEL_ENABLE_KATA
237240
ARG AKERNEL_ENABLE_RUNC
238241
ARG AKERNEL_ENABLE_FIRECRACKER

deploy/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ The node must support TC eBPF and bpffs. bpfnat does not manage host firewall
7171
policy, so custom host-network deployments must allow forwarding to and from
7272
the sandbox bridge when their `FORWARD` policy is `DROP`.
7373

74+
### systemd container identity
75+
76+
The all-in-one image, Helm node template, and standalone launcher set
77+
`container=oci` so PID 1 systemd recognizes the container and does not remount
78+
shared host filesystems read-only during shutdown. Preserve this variable in
79+
custom launchers. Applying the fix requires replacing the node Pod or
80+
standalone container; it does not repair an already read-only filesystem.
81+
7482
### Network ACLs
7583

7684
The bundled standalone, Helm, and Terraform sandboxd configurations enable

deploy/akernel/charts/core/templates/node/daemonset.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ spec:
7676
resources:
7777
{{- toYaml .Values.node.resources | nindent 10 }}
7878
env:
79+
# Required for systemd shutdown safety, including with older images.
80+
- name: container
81+
value: "oci"
7982
- name: AKERNEL_ROLE
8083
value: "node"
8184
- name: RUNSC_AKERNEL

deploy/standalone/start.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ start_node_container() {
361361
--privileged \
362362
--net bridge \
363363
--restart always \
364+
-e container=oci \
364365
-e AKS_LOCAL_MODE="true" \
365366
-e YR_RRT_CONTROL_SOCKET_PATH="/run/akernel" \
366367
-e YR_IMAGE_PROCESS_CONFIG="${YR_IMAGE_PROCESS_CONFIG}" \

0 commit comments

Comments
 (0)