Repository navigation
runsc: add a no-root-container boot mode - #13981
1 commit merged into
Conversation
2defed0 to
2041891
Compare
|
Please hold on this. There is #13929 and a follow-on PR that removes the Once those are in, I recommend extending the sandbox security posture test to verify the state of the Sentry process when it has reached the sandbox-only boot mode. This will protect against regressions for future changes to make it boot faster. |
2041891 to
8aa8f52
Compare
|
@EtiennePerot is there any blocker for the PR review now? |
There was a problem hiding this comment.
A few points of high-level feedback:
- This feature not supporting checkpoint/restore is a big drawback and I'm not sure it's going to be that useful without it, especially for things like Substrate or more generally for high-churn container orchestrating systems, because checkpoint/restore is where they get more savings than they do from fast container startup/teardown. If it's possible to support it down the line, then having it be unsupported at first is OK, but if not, in what environment do you see this functionality being used?
- The name "sandbox-only" is a bit of a misnomer, especially given that the
runsc bootprocess is long-lived and the "sandbox only" flag persists on the process argv even when there are containers running inside. It's also not obvious that "sandbox only" implies "as opposed to sandbox and containers". Better names might be something more like "reusable sandbox shell", or "recycleable kernel". - I worry that the lack of PID 1 might cause application incompatibility. PID 1 is a constant in Linux. I wonder if we should force such sandboxes to always have each container run in their own PID namespaces, so that they are their own PID 1. WDYT?
- The PR has a lot of Claude-speak, comments that are overly verbose, repetitive across files, and focusing too much about the current delta being made in the moment rather than on their long-term usefulness for maintainers and future LLMs to understand. Please write the comments in a way that makes the code understandable long-term instead. Personally, I've found that removing and then rewriting all code comments for LLM-generated PRs is a good forcing function to review and understand the code, and that the comments left in the code from that process are better-targeted to the subset that actually matters.
- The documentation markdown thing is useful to understand the feature and its semantics, but I think it is not so useful to actually use it. IMO the intended usage is through containerd using the Sandbox API, so its benefits should be reflected automatically down the line by higher-level container tooling that uses containerd. If that is the case, then we actually don't need to document it, because it becomes just a performance/architectural enhancement implementation detail, not an interface that's worth documenting to users. If you agree, then I think such documentation belongs more either in the commit message or as a markdown file or a long comment inside the code somewhere, not as a standalone user-facing website page.
|
thanks @EtiennePerot , just to clarify checkpoint/restore before i address other comments
it will be supported in a follow up PR. ~200 loc |
rename it to
The sandbox owns one root PID namespace, the namespace is created when the sentry starts. Each container started in the sandbox either gets a PID namespace of its own or joins a existing PID namespace (e.g. root pid namespace), it is decided by spec not runsc. A container gets a PID namespace of its own whenever its spec asks for one, its init process get PID 1 in that namespace, A container's processes live in the sandbox's root PID namespace only if its spec omits the PID namespace or explicitly names it. This PR doesn't change that selection. Such a container never had PID 1 anyway — in a sandbox booted with a root container (e.g. pause container for CRI), PID 1 there is the root container's init process — so its init process is PID 2 or later either way. Forcing every container into a PID namespace of its own would fix nothing in the default case, and would remove the ability to share a PID namespace across containers in a sandbox. runsc would be overriding what the container's spec asked for.
Done
move it to a standalone markdown at runsc/boot |
8aa8f52 to
2007e76
Compare
EtiennePerot
left a comment
There was a problem hiding this comment.
I ask once again to please write comments as a human :)
The comments here are difficult to make sense of.
Didn't look at the tests yet, just comments on non-test code.
Previously, the ring was held by the gofer, which works well for the case where the gofer is 1-to-1 with the Sentry. This isn't true for multi-container sandboxes (where the current approach means we wait 500ms for each container doing nothing on exit), and it's also not going to work well with the no-root-container mode introduced by PR gvisor#13981. This instead moves the job of holding the ring to a separate tiny C sidecar binary (`runsc-fd-parking`, named such to make its purpose obvious in the process table). Because this sidecar binary's job is very unimportant during startup, it defers as much of its work as possible, and because it must run for the whole lifetime of the sandbox, it minimizes its own memory footprint as aggressively as possible. Benchmarks show no measurable startup or teardown latency regression, and a +52KiB memory cost per sandbox (i.e. ~5.2 MiB per 100 sandboxes).
b466745 to
2e06810
Compare
Previously, the ring was held by the gofer, which works well for the case where the gofer is 1-to-1 with the Sentry. This isn't true for multi-container sandboxes (where the current approach means we wait 500ms for each container doing nothing on exit), and it's also not going to work well with the no-root-container mode introduced in PR #13981. This instead moves the job of holding the ring to a separate tiny C sidecar binary (`runsc-fd-parking`, named such to make its purpose obvious in the process table). Because this sidecar binary's job is very unimportant during startup, it defers as much of its work as possible, and because it must run for the whole lifetime of the sandbox, it minimizes its own memory footprint as aggressively as possible. Benchmarks show no measurable startup or teardown latency regression, and a +52KiB memory cost per sandbox (i.e. ~5.2 MiB per 100 sandboxes). FUTURE_COPYBARA_INTEGRATE_REVIEW=#14546 from EtiennePerot:pinring-sidecar e3ffc8d PiperOrigin-RevId: 976115235
Previously, the ring was held by the gofer, which works well for the case where the gofer is 1-to-1 with the Sentry. This isn't true for multi-container sandboxes (where the current approach means we wait 500ms for each container doing nothing on exit), and it's also not going to work well with the no-root-container mode introduced in PR #13981. This instead moves the job of holding the ring to a separate tiny C sidecar binary (`runsc-fd-parking`, named such to make its purpose obvious in the process table). Because this sidecar binary's job is very unimportant during startup, it defers as much of its work as possible, and because it must run for the whole lifetime of the sandbox, it minimizes its own memory footprint as aggressively as possible. Benchmarks show no measurable startup or teardown latency regression, and a +52KiB memory cost per sandbox (i.e. ~5.2 MiB per 100 sandboxes). FUTURE_COPYBARA_INTEGRATE_REVIEW=#14546 from EtiennePerot:pinring-sidecar e3ffc8d PiperOrigin-RevId: 976115235
Previously, the ring was held by the gofer, which works well for the case where the gofer is 1-to-1 with the Sentry. This isn't true for multi-container sandboxes (where the current approach means we wait 500ms for each container doing nothing on exit), and it's also not going to work well with the no-root-container mode introduced in PR #13981. This instead moves the job of holding the ring to a separate tiny C sidecar binary (`runsc-fd-parking`, named such to make its purpose obvious in the process table). Because this sidecar binary's job is very unimportant during startup, it defers as much of its work as possible, and because it must run for the whole lifetime of the sandbox, it minimizes its own memory footprint as aggressively as possible. Benchmarks show no measurable startup or teardown latency regression, and a +52KiB memory cost per sandbox (i.e. ~5.2 MiB per 100 sandboxes). FUTURE_COPYBARA_INTEGRATE_REVIEW=#14546 from EtiennePerot:pinring-sidecar e3ffc8d PiperOrigin-RevId: 976115235
Previously, the ring was held by the gofer, which works well for the case where the gofer is 1-to-1 with the Sentry. This isn't true for multi-container sandboxes (where the current approach means we wait 500ms for each container doing nothing on exit), and it's also not going to work well with the no-root-container mode introduced in PR #13981. This instead moves the job of holding the ring to a separate tiny C sidecar binary (`runsc-fd-parking`, named such to make its purpose obvious in the process table). Because this sidecar binary's job is very unimportant during startup, it defers as much of its work as possible, and because it must run for the whole lifetime of the sandbox, it minimizes its own memory footprint as aggressively as possible. Benchmarks show no measurable startup or teardown latency regression, and a +52KiB memory cost per sandbox (i.e. ~5.2 MiB per 100 sandboxes). FUTURE_COPYBARA_INTEGRATE_REVIEW=#14546 from EtiennePerot:pinring-sidecar e3ffc8d PiperOrigin-RevId: 976115235
Previously, the ring was held by the gofer, which works well for the case where the gofer is 1-to-1 with the Sentry. This isn't true for multi-container sandboxes (where the current approach means we wait 500ms for each container doing nothing on exit), and it's also not going to work well with the no-root-container mode introduced in PR #13981. This instead moves the job of holding the ring to a separate tiny C sidecar binary (`runsc-fd-parking`, named such to make its purpose obvious in the process table). Because this sidecar binary's job is very unimportant during startup, it defers as much of its work as possible, and because it must run for the whole lifetime of the sandbox, it minimizes its own memory footprint as aggressively as possible. Benchmarks show no measurable startup or teardown latency regression, and a +52KiB memory cost per sandbox (i.e. ~5.2 MiB per 100 sandboxes). FUTURE_COPYBARA_INTEGRATE_REVIEW=#14546 from EtiennePerot:pinring-sidecar e3ffc8d PiperOrigin-RevId: 976115235
Previously, the ring was held by the gofer, which works well for the case where the gofer is 1-to-1 with the Sentry. This isn't true for multi-container sandboxes (where the current approach means we wait 500ms for each container doing nothing on exit), and it's also not going to work well with the no-root-container mode introduced in PR #13981. This instead moves the job of holding the ring to a separate tiny C sidecar binary (`runsc-fd-parking`, named such to make its purpose obvious in the process table). Because this sidecar binary's job is very unimportant during startup, it defers as much of its work as possible, and because it must run for the whole lifetime of the sandbox, it minimizes its own memory footprint as aggressively as possible. Benchmarks show no measurable startup or teardown latency regression, and a +52KiB memory cost per sandbox (i.e. ~5.2 MiB per 100 sandboxes). FUTURE_COPYBARA_INTEGRATE_REVIEW=#14546 from EtiennePerot:pinring-sidecar e3ffc8d PiperOrigin-RevId: 976115235
Previously, the ring was held by the gofer, which works well for the case where the gofer is 1-to-1 with the Sentry. This isn't true for multi-container sandboxes (where the current approach means we wait 500ms for each container doing nothing on exit), and it's also not going to work well with the no-root-container mode introduced in PR #13981. This instead moves the job of holding the ring to a separate tiny C sidecar binary (`runsc-fd-parking`, named such to make its purpose obvious in the process table). Because this sidecar binary's job is very unimportant during startup, it defers as much of its work as possible, and because it must run for the whole lifetime of the sandbox, it minimizes its own memory footprint as aggressively as possible. Benchmarks show no measurable startup or teardown latency regression, and a +52KiB memory cost per sandbox (i.e. ~5.2 MiB per 100 sandboxes). FUTURE_COPYBARA_INTEGRATE_REVIEW=#14546 from EtiennePerot:pinring-sidecar e3ffc8d PiperOrigin-RevId: 976115235
Previously, the ring was held by the gofer, which works well for the case where the gofer is 1-to-1 with the Sentry. This isn't true for multi-container sandboxes (where the current approach means we wait 500ms for each container doing nothing on exit), and it's also not going to work well with the no-root-container mode introduced in PR #13981. This instead moves the job of holding the ring to a separate tiny C sidecar binary (`runsc-fd-parking`, named such to make its purpose obvious in the process table). Because this sidecar binary's job is very unimportant during startup, it defers as much of its work as possible, and because it must run for the whole lifetime of the sandbox, it minimizes its own memory footprint as aggressively as possible. Benchmarks show no measurable startup or teardown latency regression, and a +52KiB memory cost per sandbox (i.e. ~5.2 MiB per 100 sandboxes). FUTURE_COPYBARA_INTEGRATE_REVIEW=#14546 from EtiennePerot:pinring-sidecar e3ffc8d PiperOrigin-RevId: 976115235
Previously, the ring was held by the gofer, which works well for the case where the gofer is 1-to-1 with the Sentry. This isn't true for multi-container sandboxes (where the current approach means we wait 500ms for each container doing nothing on exit), and it's also not going to work well with the no-root-container mode introduced in PR #13981. This instead moves the job of holding the ring to a separate tiny C sidecar binary (`runsc-fd-parking`, named such to make its purpose obvious in the process table). Because this sidecar binary's job is very unimportant during startup, it defers as much of its work as possible, and because it must run for the whole lifetime of the sandbox, it minimizes its own memory footprint as aggressively as possible. Benchmarks show no measurable startup or teardown latency regression, and a +52KiB memory cost per sandbox (i.e. ~5.2 MiB per 100 sandboxes). COPYBARA_INTEGRATE_REVIEW=#14546 from EtiennePerot:pinring-sidecar e3ffc8d PiperOrigin-RevId: 980553731
2e06810 to
cb17b2f
Compare
| // task, or nil if there is no global init or it has already exited. | ||
| // | ||
| // Does not take k.extMu; CreateProcess calls this while holding it. | ||
| func (k *Kernel) globalInitMountNamespace() *vfs.MountNamespace { |
There was a problem hiding this comment.
nit: s/globalInitMountNamespace/globalInitMountNamespaceLocked
There was a problem hiding this comment.
Only CreateProcess holds k.extMu when it calls this function. The two supervisorContext.Value callers do not hold it.
There was a problem hiding this comment.
It's standard practice in gVisor to suffix the function that requires the mutex to be locked with Locked. The upper-lower case difference is hard to spot and easy to mix. Locked also allows for both functions to be package public/private.
There was a problem hiding this comment.
I don't see the change. Please update your changes.
There was a problem hiding this comment.
done
sorry, I forgot to push the new comit
cb17b2f to
dcec05f
Compare
ateom-microvm runs no pause container, but SandboxConfig required a pauseImage for every class, so atelet pulled the image and built a pause bundle for each micro-VM actor that nothing used. pauseImage is now required for gvisor and rejected for microvm. atelet only checks for it on gVisor and skips the pause bundle when there is no pause image. gvisor/gvisor#13981 will enable this for gvisor O(soon) and then we can clean this up entirely. This is a less contentious offshoot of the sandboxConfig discussion.
dcec05f to
5688b11
Compare
Add `runsc create/run/boot --no-root-container`, which boots a sandbox from a spec describing only the sandbox: no Process and no Root. The kernel comes up empty and containers are added afterwards as subcontainers. This exists for the containerd Sandbox API, which lands separately. Under CRI with `sandboxer = "shim"` there is no pause container to stand in for the pod: containerd leaves Sandbox.Spec unset, so the sandbox bundle has no config.json, and there is neither a rootfs nor a process to run. runsc has so far required both. Limitations: - Checkpoint/restore is refused for a no-root-container sandbox. The kernel state round-trips, but `runsc restore` cannot be told the spec describes a sandbox, so it either rejects it or dereferences the absent Process, and the loader would restore the sandbox as if it had a gofer. Lifting it is a --no-root-container flag, a nil guard, and skipping the sandbox in the restorer's per-container loop; deferred rather than shipped untested.
5688b11 to
31cb23e
Compare
Add `runsc create/run/boot --no-root-container`, which boots a sandbox from a spec describing only the sandbox: no Process and no Root. The kernel comes up empty and containers are added afterwards as subcontainers. This exists for the containerd Sandbox API, which lands separately. Under CRI with `sandboxer = "shim"` there is no pause container to stand in for the pod: containerd leaves Sandbox.Spec unset, so the sandbox bundle has no config.json, and there is neither a rootfs nor a process to run. runsc has so far required both. runsc/boot/no_root_container.md walks through booting one from the command line and says what a pod without a pause container does not have. Limitations: - Checkpoint/restore is refused for a no-root-container sandbox. The kernel state round-trips, but `runsc restore` cannot be told the spec describes a sandbox, so it either rejects it or dereferences the absent Process, and the loader would restore the sandbox as if it had a gofer. Lifting it is a --no-root-container flag, a nil guard, and skipping the sandbox in the restorer's per-container loop; deferred rather than shipped untested. FUTURE_COPYBARA_INTEGRATE_REVIEW=#13981 from milantracy:sandbox-only 31cb23e PiperOrigin-RevId: 994826110
Add `runsc create/run/boot --no-root-container`, which boots a sandbox from a spec describing only the sandbox: no Process and no Root. The kernel comes up empty and containers are added afterwards as subcontainers. This exists for the containerd Sandbox API, which lands separately. Under CRI with `sandboxer = "shim"` there is no pause container to stand in for the pod: containerd leaves Sandbox.Spec unset, so the sandbox bundle has no config.json, and there is neither a rootfs nor a process to run. runsc has so far required both. runsc/boot/no_root_container.md walks through booting one from the command line and says what a pod without a pause container does not have. Limitations: - Checkpoint/restore is refused for a no-root-container sandbox. The kernel state round-trips, but `runsc restore` cannot be told the spec describes a sandbox, so it either rejects it or dereferences the absent Process, and the loader would restore the sandbox as if it had a gofer. Lifting it is a --no-root-container flag, a nil guard, and skipping the sandbox in the restorer's per-container loop; deferred rather than shipped untested. FUTURE_COPYBARA_INTEGRATE_REVIEW=#13981 from milantracy:sandbox-only 31cb23e PiperOrigin-RevId: 994826110
Add `runsc create/run/boot --no-root-container`, which boots a sandbox from a spec describing only the sandbox: no Process and no Root. The kernel comes up empty and containers are added afterwards as subcontainers. This exists for the containerd Sandbox API, which lands separately. Under CRI with `sandboxer = "shim"` there is no pause container to stand in for the pod: containerd leaves Sandbox.Spec unset, so the sandbox bundle has no config.json, and there is neither a rootfs nor a process to run. runsc has so far required both. runsc/boot/no_root_container.md walks through booting one from the command line and says what a pod without a pause container does not have. Limitations: - Checkpoint/restore is refused for a no-root-container sandbox. The kernel state round-trips, but `runsc restore` cannot be told the spec describes a sandbox, so it either rejects it or dereferences the absent Process, and the loader would restore the sandbox as if it had a gofer. Lifting it is a --no-root-container flag, a nil guard, and skipping the sandbox in the restorer's per-container loop; deferred rather than shipped untested. FUTURE_COPYBARA_INTEGRATE_REVIEW=#13981 from milantracy:sandbox-only 31cb23e PiperOrigin-RevId: 994826110
Add `runsc create/run/boot --no-root-container`, which boots a sandbox from a spec describing only the sandbox: no Process and no Root. The kernel comes up empty and containers are added afterwards as subcontainers. This exists for the containerd Sandbox API, which lands separately. Under CRI with `sandboxer = "shim"` there is no pause container to stand in for the pod: containerd leaves Sandbox.Spec unset, so the sandbox bundle has no config.json, and there is neither a rootfs nor a process to run. runsc has so far required both. runsc/boot/no_root_container.md walks through booting one from the command line and says what a pod without a pause container does not have. Limitations: - Checkpoint/restore is refused for a no-root-container sandbox. The kernel state round-trips, but `runsc restore` cannot be told the spec describes a sandbox, so it either rejects it or dereferences the absent Process, and the loader would restore the sandbox as if it had a gofer. Lifting it is a --no-root-container flag, a nil guard, and skipping the sandbox in the restorer's per-container loop; deferred rather than shipped untested. FUTURE_COPYBARA_INTEGRATE_REVIEW=#13981 from milantracy:sandbox-only 31cb23e PiperOrigin-RevId: 994826110
Add `runsc create/run/boot --no-root-container`, which boots a sandbox from a spec describing only the sandbox: no Process and no Root. The kernel comes up empty and containers are added afterwards as subcontainers. This exists for the containerd Sandbox API, which lands separately. Under CRI with `sandboxer = "shim"` there is no pause container to stand in for the pod: containerd leaves Sandbox.Spec unset, so the sandbox bundle has no config.json, and there is neither a rootfs nor a process to run. runsc has so far required both. runsc/boot/no_root_container.md walks through booting one from the command line and says what a pod without a pause container does not have. Limitations: - Checkpoint/restore is refused for a no-root-container sandbox. The kernel state round-trips, but `runsc restore` cannot be told the spec describes a sandbox, so it either rejects it or dereferences the absent Process, and the loader would restore the sandbox as if it had a gofer. Lifting it is a --no-root-container flag, a nil guard, and skipping the sandbox in the restorer's per-container loop; deferred rather than shipped untested. FUTURE_COPYBARA_INTEGRATE_REVIEW=#13981 from milantracy:sandbox-only 31cb23e PiperOrigin-RevId: 994826110
847fc88
Add
runsc create/run/boot --no-root-container, which boots a sandbox from aspec describing only the sandbox: no Process and no Root. The kernel comes up
empty and containers are added afterwards as subcontainers.
This exists for the containerd Sandbox API, which lands separately. Under
CRI with
sandboxer = "shim"there is no pause container to stand in forthe pod: containerd leaves Sandbox.Spec unset, so the sandbox bundle has no
config.json, and there is neither a rootfs nor a process to run. runsc has
so far required both.
runsc/boot/no_root_container.md walks through booting one from the
command line and says what a pod without a pause container does not have.
Limitations:
state round-trips, but
runsc restorecannot be told the spec describes asandbox, so it either rejects it or dereferences the absent Process, and
the loader would restore the sandbox as if it had a gofer. Lifting it is a
--no-root-container flag, a nil guard, and skipping the sandbox in the
restorer's per-container loop; deferred rather than shipped untested.