Skip to content

Commit 3ed73e4

Browse files
fix(kubernetes): preserve sandbox ownership when seeding workspace
The workspace-init container seeds a fresh PVC as root and extracted with --no-same-owner, so every seeded path landed owned by uid 0. A mode-0700 home directory shipped by the image (~/.config, ~/.cache) was then unreachable for the workload. fsGroup does not compensate: kubelet applies it when the volume is mounted, which is before the init container writes anything. Under the sidecar topology the supervisor's privileged workspace reconciliation does not run, so the seeded ownership is load-bearing. Rewrite ownership to the resolved sandbox identity while building the transfer archive instead. Seeding stays root, so images that ship root-owned private content still seed, and no recursive chown runs over the workspace (the pattern that broke on read-only submounts in #2294). Modes and timestamps are still not restored. Two environments cannot restore ownership, and neither may turn a permissions problem into a pod that will not start. --owner/--group are GNU extensions and this init container runs the sandbox image itself, so the script probes tar once and drops to the previous flags on a minimal base such as Alpine, which provides BusyBox tar. A writable backend can also accept the write but reject chown, root-squashed NFS being the usual case; extraction retries without ownership, and the sentinel is recorded when either attempt succeeds so a workspace that never seeded is never marked initialized. The script builder now takes its source and destination paths as arguments so the retry and sentinel logic can be driven directly in tests with a stub tar. A real tar cannot cover it: ownership is only restored under uid 0, so an unprivileged run skips the chown and always succeeds. Signed-off-by: loveRhythm1990 <[email protected]>
1 parent 02b664b commit 3ed73e4

3 files changed

Lines changed: 452 additions & 34 deletions

File tree

‎architecture/compute-runtimes.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,25 @@ identity is absent, malformed, unknown, ambiguous, or resolves to UID/GID 0.
425425
The supervisor itself remains root so it can establish isolation before
426426
starting unprivileged children.
427427

428+
When the Kubernetes driver seeds a fresh workspace PVC from the image, the
429+
seeded tree is written as the resolved sandbox UID/GID. The init container runs
430+
as root so it can read every source path, and rewrites ownership while building
431+
the transfer archive rather than chowning the workspace afterwards. Ownership
432+
must be established during seeding: `fsGroup` is applied by kubelet when the
433+
volume is mounted, which is before the init container writes anything, and the
434+
sidecar topology does not perform the supervisor's privileged workspace
435+
reconciliation. Modes and timestamps are not restored, so a nested read-only
436+
mount under the workspace is never chmod'ed during seeding.
437+
438+
Two environments cannot restore ownership, and neither turns a permissions
439+
problem into a pod that will not start. The rewrite uses GNU tar extensions and
440+
the init container runs the sandbox image itself, so an image whose tar lacks
441+
them — a minimal base such as Alpine, which provides BusyBox tar — seeds with
442+
the previous flags instead. A writable backend can also accept the write but
443+
reject `chown`, root-squashed NFS being the usual case; extraction then retries
444+
without ownership. The sentinel is recorded when either attempt succeeds, so a
445+
workspace that never seeded is never marked initialized.
446+
428447
Kubernetes can run the supervisor in the default combined topology or in a
429448
sidecar topology. Combined mode keeps network and process supervision in the
430449
agent container. Sidecar mode runs network enforcement, the proxy, and gateway

0 commit comments

Comments
 (0)