Skip to content

Right-size sandbox to the worker pod's CPU/memory - #679

Open
Chenyi Wang (chw120) wants to merge 1 commit into
agent-substrate:mainfrom
chw120:microvm-rightsizing
Open

Right-size sandbox to the worker pod's CPU/memory#679
Chenyi Wang (chw120) wants to merge 1 commit into
agent-substrate:mainfrom
chw120:microvm-rightsizing

Conversation

@chw120

Copy link
Copy Markdown

Both sandbox runtimes (gVisor and micro-VM) previously sized themselves to the whole host rather than the ateom worker pod they run in. Add a common seam that discovers the pod's limits (Kubernetes downward API) and applies them, so each sandbox matches its pod.

internal/sizing (shared by both runtimes):

  • Discover() reads ATEOM_SIZE_CPU_MILLI / ATEOM_SIZE_MEMORY_BYTES, injected by the controller via resourceFieldRef against the pod's limits.cpu / limits.memory.
  • ApplyToOCISpec() writes cgroup v2 CPU quota/period + memory.max into the OCI spec (skips unset fields; no-op when neither is set).
  • VCPUs() rounds milliCPU up to whole vCPUs.

atecontroller: inject the two downward-API env vars on the ateom container.

ateom-gvisor: apply sizing to the per-container cgroup leaf and pass runsc --cpu-num-from-quota on create/restore so the sentry's vCPU count is provisioned from the pod's CPU quota (not all host CPUs).

ateom-microvm: size the cloud-hypervisor VmConfig (BootVcpus/MaxVcpus and Memory) to the pod, reserving a margin of guest RAM for the VMM + virtiofsd (host processes in the pod cgroup) so the pod does not OOM. The margin defaults to 256 MiB and is tunable via --vmm-mem-reserve-mib.

demos: set template.resources (requests/limits) on the WorkerPools so the downward API has real limits to surface.

  • Tests pass
  • Appropriate changes to documentation are included in the PR

Both sandbox runtimes (gVisor and micro-VM) previously sized themselves to
the whole host rather than the ateom worker pod they run in. Add a common
seam that discovers the pod's limits (Kubernetes downward API) and applies
them, so each sandbox matches its pod.

internal/sizing (shared by both runtimes):
- Discover() reads ATEOM_SIZE_CPU_MILLI / ATEOM_SIZE_MEMORY_BYTES, injected
  by the controller via resourceFieldRef against the pod's limits.cpu /
  limits.memory.
- ApplyToOCISpec() writes cgroup v2 CPU quota/period + memory.max into the
  OCI spec (skips unset fields; no-op when neither is set).
- VCPUs() rounds milliCPU up to whole vCPUs.

atecontroller: inject the two downward-API env vars on the ateom container.

ateom-gvisor: apply sizing to the per-container cgroup leaf and pass
runsc --cpu-num-from-quota on create/restore so the sentry's vCPU count is
provisioned from the pod's CPU quota (not all host CPUs).

ateom-microvm: size the cloud-hypervisor VmConfig (BootVcpus/MaxVcpus and
Memory) to the pod, reserving a margin of guest RAM for the VMM + virtiofsd
(host processes in the pod cgroup) so the pod does not OOM. The margin
defaults to 256 MiB and is tunable via --vmm-mem-reserve-mib.

demos: set template.resources (requests/limits) on the WorkerPools so the
downward API has real limits to surface.
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