Repository navigation
Open
Labels
area/apiUser-facing API changesarea/api-machineryarea/cliarea/nodekind/bugSomething isn't working / bugfixes
Description
Summary & Root Cause
- Part 1: API validation enforces only
memory_bytes > 0, andociResourcespasses the value through unclamped as the container's memory limit. CPU, by contrast, is raised to a kernel floor. Nothing stops a value far below what gVisor needs to start a sandbox, so the failure moves from admission (400) to the first wake. There,runsc createis killed and the actor goes toCRASHED. The kernel OOM kill (Memory cgroup out of memory: Killed process (runsc)) also took down the shared worker container (OOMKilled, restart). One tenant template can therefore restart a worker pod that other actors may be using. The code examined here does not establish why the OOM escapes the sandbox's limit and reaches the worker container. That part is observed behavior only. - Part 2: List RPCs filter rows by atespace without checking that the atespace exists, so a typo returns an empty page with RC 0.
- Part 3:
CreateActorresolves the template before anything checks the atespace. A missing atespace and a missing template both become the sameerrActorTemplateNotFound, andapierror.FromErrordrops theObjectRefcontext thatresolveActorTemplateadded. - Part 4: The store collapses every foreign-key violation into one sentinel. The handler cannot say which child resource type (actors, templates, tags) blocks the delete, and the CLI help mentions only actors.
Affected Code Locations
- Part 1 (tiny
memoryBytesaccepted and OOM-kills worker on wake):api/ateapi/v1/ateapi.proto:1235-1248:Resources.memory_bytesonly has+k8s:minimum=0. There is no lower bound.cmd/ateapi/internal/apivalidation/zz_generated.validation.go:7541-7570: the generated check formemory_bytesisvalidate.Minimum(..., 0)only.cmd/ateapi/internal/apivalidation/actor_template.go:86-97:ValidateCustom_ActorTemplate_Resourcesrejects only== 0(Required).cmd/ateapi/internal/apivalidation/zz_generated.validation.go:7526-7531: for CPU,-100hitsMinimum(0)("must be greater than or equal to 0"), while0hits the customRequiredatactor_template.go:90-91. That is why the two errors differ.internal/ocispec/ocispec.go:63-78:ociResourcescopiesmemory_bytesunchanged into the OCIlinux.resources.memory.limit(lines 69-71). CPU gets a kernel-minimum floor (cpuQuotaMinUS, lines 53-57 and 73). Memory has no floor at all.internal/ocispec/ocispec.go:161-164: the container spec'sLinux.Resourcesis set fromociResources.
- Part 2 (
get/List*in a missing atespace exits 0):cmd/ateapi/internal/controlapi/actor.go:225-242:ListActorspasses the atespace straight to the store with no existence check. The same applies toactor_template.go:103-118(ListActorTemplates) andtag.go:87-101(ListTags, which carries// TODO: implement thisat line 99).- Contrast:
cmd/kubectl-ate/internal/cmd/access_policy.go:170-185(requireScope) callsGetAtespaceand printsatespace %q not found.
- Part 3 (
CreateActorhides whether atespace or template is missing and dropsObjectRef):cmd/ateapi/internal/controlapi/actor.go:86:CreateActorcallsresolveActorTemplatefirst.cmd/ateapi/internal/controlapi/actor_template.go:152-171:errActorTemplateNotFound = apierror.FailedPrecondition("actor template not found")(line 156), wrapped as"%w; ObjectRef: %s "(line 165).internal/apierror/apierror.go:128-139:FromErrorreturnsapiErr.Error(), the apierror's own message without the wrapping context, so theObjectRefsuffix never reaches the client.cmd/ateapi/internal/controlapi/actor.go:161-163: theAtespace %s not foundbranch exists but is unreachable for a missing atespace, because template lookup fails first.
- Part 4 (
DeleteAtespacereturns generic "not empty" message vs.--help):cmd/ateapi/internal/store/atepg/atespace.go:136-138: a foreign-key violation maps to barestore.ErrFailedPrecondition.cmd/ateapi/internal/controlapi/atespace.go:120-121: the server formats this asAtespace %s is not empty.cmd/kubectl-ate/internal/cmd/atespace.go:102:Short: "Delete an empty atespace (fails if any actors remain)".
Note: Earlier write-ups cited
actor.go:86, 161-163as the location oferrActorTemplateNotFound. At15b58199the variable and its wrapping live inactor_template.go:152-171, andactor.go:161-163is the unreachable "Atespace not found" branch.
Detailed Reproduction Guide
- Tiny memory limit:
metadata:
name: s5-mem1k
atespace: ate-demo-counter
workerSelector:
matchLabels:
workload: counter
resources:
limits:
cpuMillicores: "250"
memoryBytes: "1024"
containers:
- name: counter
image: gcr.io/<PROJECT_ID>/ate-images/counter
command:
- /ko-app/counterkubectl ate create actor-template -f s5-mem1k.yaml
kubectl ate create actor s5-mem1k-actor -a ate-demo-counter --template s5-mem1k
# Wake through atenet-router (mTLS client), for example:
curl -sS -X POST --cert credential-bundle.pem --key credential-bundle.pem --cacert router-ca.pem \
-H "ate-target-actor: ate-demo-counter/s5-mem1k-actor" https://atenet-router.ate-system.svc/
kubectl ate get actor s5-mem1k-actor -a ate-demo-counter -o yaml
# Check the worker pod that hosted the wake for an OOM restart:
kubectl -n ate-demo-counter get pods -o custom-columns=NAME:.metadata.name,RESTARTS:.status.containerStatuses[0].restartCount,LAST:.status.containerStatuses[0].lastState.terminated.reason
kubectl get events -A --field-selector reason=OOMKilling- CPU
0vs-100(same template withcpuMillicores: "0", then"-100"):
kubectl ate create actor-template -f s5-cpu0.yaml
kubectl ate create actor-template -f s5-cpuneg.yaml- Missing atespace on list:
kubectl ate get actors -a does-not-exist
kubectl ate get actor-templates -a does-not-exist
kubectl ate get tags -a does-not-exist
kubectl ate get access-policy -a does-not-exist- Missing atespace vs missing template, and the delete message:
kubectl ate create actor x -a does-not-exist --template counter
kubectl ate create actor x -a ate-demo-counter --template nope
kubectl ate delete atespace ate-demo-counter
kubectl ate delete atespace --help | head -n 1Expected vs. Actual Behavior
- Expected:
memoryBytes: 1024is rejected at create time withInvalidArgumentand a documented minimum. A sandbox that exceeds its memory limit is contained to that actor and does not affect the worker pod. CPU0and-100produce consistent messages.- Listing in a missing atespace returns
NotFound: atespace "does-not-exist" not found, asget access-policydoes. CreateActorsays which of atespace or template is missing, including<atespace>/<template>.DeleteAtespacenames the blocking resource types, and--helpdoes not say "actors" only.
- Actual:
- The template is admitted (RC=0). The wake returns HTTP 500 and the actor goes
ACTOR_STATE_CRASHED(runsc createkilled). The shared worker container is also OOM-killed and restarted. CPU0givesRequired valuebut-100givesmust be greater than or equal to 0. - The three list commands exit 0 with only a header.
- Both
create actorcases return the identicalactor template not found. - Delete returns
Atespace ate-demo-counter is not empty, while help says(fails if any actors remain).
- The template is admitted (RC=0). The wake returns HTTP 500 and the actor goes
Observed Output & Logs
$ kubectl ate create actor-template -f s5-mem1k.yaml
ATESPACE NAME GOLDEN TAG ERROR AGE
ate-demo-counter s5-mem1k 0s
RC=0
$ ate_curl s5-mem1k-actor
error resuming actor ate-demo-counter/s5-mem1k-actor
HTTP_CODE:500status:
assignedNode: gke-worker-node-1
crash:
crashTime: "2026-10-27T00:39:30.763493847Z"
message: 'resume failed: atelet Run: while calling worker RunWorkload: rpc error:
code = Internal desc = while creating the sandbox: while running `runsc create`:
signal: killed'
state: ACTOR_STATE_CRASHED$ kubectl ate create actor-template -f s5-cpu0.yaml
Error: failed to create actor template: rpc error: code = InvalidArgument desc = actor_template.resources.limits.cpu_millicores: Required value
RC=1
$ kubectl ate create actor-template -f s5-cpuneg.yaml
Error: failed to create actor template: rpc error: code = InvalidArgument desc = actor_template.resources.limits.cpu_millicores: Invalid value: -100: must be greater than or equal to 0
RC=1
$ kubectl ate get actors -a does-not-exist
ATESPACE NAME TEMPLATE STATE WORKER POD WORKER IPS VERSION AGE
RC=0
$ kubectl ate get actor-templates -a does-not-exist
ATESPACE NAME GOLDEN TAG ERROR AGE
RC=0
$ kubectl ate get tags -a does-not-exist
ATESPACE NAME SCOPE STATE SNAPSHOT FIDELITY AGE
RC=0
$ kubectl ate get access-policy -a does-not-exist
Error: atespace "does-not-exist" not found
RC=1
$ kubectl ate create actor x -a does-not-exist --template counter
Error: failed to create actor: rpc error: code = FailedPrecondition desc = actor template not found
RC=1
$ kubectl ate create actor x -a ate-demo-counter --template nope
Error: failed to create actor: rpc error: code = FailedPrecondition desc = actor template not found
RC=1
$ kubectl ate delete atespace ate-demo-counter
Error: failed to delete atespace: rpc error: code = FailedPrecondition desc = Atespace ate-demo-counter is not empty
RC=1
$ kubectl ate delete atespace --help | head -n 1
Delete an empty atespace (fails if any actors remain)$ kubectl ate create actor-template -f r3-mem1k.yaml
ATESPACE NAME GOLDEN TAG ERROR AGE
ate-demo-counter r3-mem1k 0s
RC=0
$ ate_curl ate-demo-counter/r3-mem1k-actor
error resuming actor ate-demo-counter/r3-mem1k-actor
HTTP_CODE:500 TIME_TOTAL:0.521037s{
"state": "ACTOR_STATE_CRASHED",
"crash": {
"crashTime": "2026-10-27T02:00:27.157823263Z",
"message": "resume failed: atelet Run: while calling worker RunWorkload: rpc error: code = Internal desc = while creating the sandbox: while running `runsc create`: signal: terminated"
},
"uid": "7d894d64-525c-450b-beb9-954cd9581553"
}Metadata
Metadata
Assignees
Labels
area/apiUser-facing API changesarea/api-machineryarea/cliarea/nodekind/bugSomething isn't working / bugfixes
Activity
yjjnls commentedon Nov 23, 2026
Focusing on Part 1. Parts 2 to 4 are separate changes and I have not dug into them.
I re-checked the admission path on main (
8368e765b) and it still behaves as reported.memory_bytescarries only+k8s:minimum=0(api/ateapi/v1/ateapi.proto:1243-1247), andValidateCustom_ActorTemplate_Resources(cmd/ateapi/internal/apivalidation/actor_template.go:86-95) rejects exactly0for cpu and memory, so1024passes admission.ociResources(internal/ocispec/ocispec.go:65-80) copies memory intolinux.resources.memory.limitunchanged, while CPU is raised tocpuQuotaMinUS. The gVisor sandbox leaf path applies memory verbatim too (internal/sizing/sizing.go,ApplyToOCISpec), so no spec-building path floors memory, and nothing has added a minimum since this was filed.On the worker side there is protection this repro probably already ran with, and it points at a narrower remaining gap than the OOM escaping the sandbox outright:
15b58199descends from it. A microVM actor using more host memory than it booked no longer takes down its worker #3429 (microVM) followed on 10-29. Both are ancestors ofv1.0.0.memory.maxformemory.highat the same limit and armscgroup.MemoryGuard(cmd/ateworker-gvisor/memlimit.go:36-51). The guard runs every 250ms and kills a cgroup stuck atmemory.highwithcgroup.kill, reporting "killed for exceeding its memory limit".internal/ateworker/cgroup/memguard.go:28-38explains the design: with runc 1.5.2+ on systemd 253-258 the worker scope hasOOMPolicy=kill, so any kernel OOM under it stops the whole worker even when the kill is confined to one actor's cgroup.That guard only covers the post-create window. During
runsc createthe leaf still carriesmemory.maxfrom the OCI spec (runsc reads it back to size the sentry), and a 1 KiB limit cannot fit the sandbox bootstrap, so the kernel memcg OOM path stays reachable exactly where this report saw the failure (while running runsc create: signal: killed, workerOOMKilled). If the kind install was at the cited commit, the observed worker restart happened with #3106 already in, which points at the create window as the remaining escape. A re-run on main should confirm. Also note the guard only arms when the node has PSI (cmd/ateworker-gvisor/main.go:271-274). Without PSI the worker keepsmemory.maxand the old failure mode returns.For any limit that does get past create, the guard kills fast.
MemoryWatch.Checktreats overshoot asused > limit + min(limit/16, memoryOvershootMax)(internal/ateworker/cgroup/memwatch.go:87). At 1 KiB the allowance is 64 bytes, so nothing survives the first tick. Containment works: the actor ends upCRASHEDwith the guard's message and the worker keeps running. The template is still admitted though, and the diagnosis only arrives at the first wake.Suggested acceptance and fix:
CreateActorTemplatewithmemoryBytes: 1024returnsInvalidArgument(400) naming a documented minimum, consistent with the CPU boundary errors.ociResources. Placement books the limit plus runtime overhead (cmd/ateapi/internal/scheduling/scheduling.go:316-326), so clamping only when building the spec would book less memory than the runtime actually uses. Either reject below a per-runtime minimum, or raise and store the value so booking sees it.cpuQuotaMinUSis the existing precedent for the clamp variant: a limit under the floor "is raised to this floor rather than producing a spec the guest refuses".Happy to re-run the 1 KiB repro on main and report what the worker and actor state show.
Comment drafted with AI assistance, then reviewed and verified against
8368e765bby hand.