Repository navigation
feat(executor): bound file calls and gate readiness on /workspace - #2995
Conversation
6d0cc1c to
ab1c422
Compare
562cc6f to
d052625
Compare
d052625 to
b1cfb12
Compare
/workspace/workspace
rdimitrov
left a comment
There was a problem hiding this comment.
Checked this against #2698 and the storage-failure section of the Kubernetes execution design. It matches both: file calls are bounded, the readiness check touches /workspace, ENOSPC reaches the agent as a tool error, and nothing under engine/ changed.
What I ran locally on this head:
- Focused
-racetests forexecutorrpc/...,executionexecutor,executionenv,executioncontroller,executionclient,cmd/mecatl-executor, andcmd/mecaexec: all pass. executor:smokepasses. I then ran the image with-health-listen=:7444on a 2 MiB tmpfs/workspace, which exercises the LinuxO_TMPFILEpath:- the server,
FileService, andCommandServiceall reportSERVING, and an unknown service returnsNotFound; - when the volume is full,
mecaexec createfails withResourceExhausted: workspace storage is full, health staysSERVING, and the create works again once space is freed; - after
mkfifo p,mecaexec -file-timeout 3s read preturnsclass: storage-timeoutafter 3s, and other file calls keep working.
- the server,
- The Kind production-profile shards pass in CI on this head.
One blocking issue is inline: an agent command can make its own environment permanently not ready.
The second point doesn't block the code, but it should go in the release notes. Workload images are pinned by digest per template revision, and an older /mecatl-executor exits at startup on the unknown -health-listen flag. After the provider upgrade, existing Pods are fine because the drift check accepts them. Two things fail, though: new environments on template revisions that still pin a pre-upgrade workload image, and any ReplaceExecutor on an existing environment, because the replacement Pod gets the new args. Both end up crash-looping instead of becoming ready. The PR description says this, but operators will only see it if the upgrade notes say to publish template revisions on a rebuilt workload image before upgrading the provider, or in the same step.
b1cfb12 to
813a8f0
Compare
Every FileService call from `executorclient.Workspace` now runs under a one-minute deadline (`WithFileCallTimeout`), covering whole streams. When it expires the call fails with `ErrStorageTimeout`: "workspace storage did not respond in time; a write may still have completed". A syscall blocked on storage cannot be interrupted, so the executor may still finish the operation; the deadline only stops the agent waiting. The caller's own cancellation or deadline is still reported as such, and `callContextError` waits for the deadline when gRPC reports it before the context's timer fires. `mecaexec` gains `-file-timeout`. Workspace errors named by `fileserver.WithStorageFullErrors` (`ENOSPC` and `EDQUOT` on the executor) map to `RESOURCE_EXHAUSTED` with "workspace storage is full" instead of a generic `INTERNAL`. `mecatl-executor serve -health-listen` serves plaintext gRPC health, reporting the server and its enabled services `SERVING` only while `/workspace` accepts a new file within 30 seconds, checked every 2 seconds. On Linux the check creates an unnamed `O_TMPFILE` so no reader sees it, falling back to a named temporary file. A check blocked past its timeout is abandoned and no new one starts until it returns. A full volume (`ENOSPC`, `EDQUOT`) and a root the agent made read-only (`EACCES`, `EPERM`) stay ready, so the agent can fix them. New executor Pods get `-health-listen=:7444`, a `health` container port, and a kubelet gRPC readiness probe on that port in place of the TCP probe, since the kubelet's gRPC probe cannot present the client certificate the main server requires. The drift check still accepts Pods created with the previous args, ports, and TCP probe, so existing environments survive the upgrade. Closes: #2698
813a8f0 to
ca15d29
Compare
Summary
Stops file tool calls hanging on unavailable storage, makes executor readiness depend on
/workspacebeing writable, and reports full storage as a clear tool error.executorclient.Workspaceruns under a one-minute deadline (WithFileCallTimeout) covering whole streams. On expiry the tool getsErrStorageTimeout: "workspace storage did not respond in time; a write may still have completed". A syscall blocked on storage cannot be interrupted, so the executor may still finish the operation; the deadline only stops the agent waiting. The caller's own cancellation or deadline is still reported as such.mecaexecgains-file-timeout.ENOSPCandEDQUOTmap toRESOURCE_EXHAUSTED("workspace storage is full") instead of a genericINTERNAL, injected throughfileserver.WithStorageFullErrorsbecause depguard keepssyscallout ofinternal/executorrpc.mecatl-executor serve -health-listenserves plaintextgrpc.health.v1, reportingSERVINGonly while/workspaceaccepts a new file within 30 seconds (checked every 2 seconds, unnamedO_TMPFILEon Linux). A stuck check is abandoned and not repeated until it returns. A full volume (ENOSPC,EDQUOT) or a/workspacethe agent made read-only (EACCES,EPERM) stays ready, so the agent can fix it.-health-listen=:7444, ahealthport, and a kubelet gRPC readiness probe in place of the TCP probe, because the kubelet cannot present the client certificate the main server requires. The drift check still accepts Pods with the previous args, ports and TCP probe.Issue relationship
Closes #2698
Type of change
Test plan
Baseline checks
task lint)task test): left to CItask test:race): left to CI; focused-raceruns pass forinternal/executorrpc/...,internal/executionexecutor,internal/executionenv,internal/adapter/executioncontroller,internal/adapter/executionclient/...,cmd/mecatl-executorandcmd/mecaexecgo run ./cmd/mecademo)task docs)task site:build)task api:check)task api:update+engine/CHANGELOG.mdAlso:
go vetwith every build tag on Linux and darwin (only the known darwine2ePdeathsigfailure, also on main). New tests cover a FileService that never answers (unary, server-stream after one chunk, client-stream) failing withErrStorageTimeoutafter the bound, the caller's own deadline and cancellation still reported as such,fstools.WriteToolfailing on a hung call and onENOSPC/EDQUOT, health goingNOT_SERVINGwhen/workspaceis removed or not writable, and the drift check for new, legacy and mixed Pod shapes. TheO_TMPFILEpath was run in a Linux container. The Kind production qualification passed in CI on an earlier head with the same readiness probe.Changes
internal/executorrpc/executorclient/client.go,workspace.goErrStorageTimeout, error classificationinternal/executorrpc/fileserver/server.goWithStorageFullErrors→RESOURCE_EXHAUSTEDinternal/executionexecutor/workspace_health*.go,workspace_touch_*.go/workspacehealth checkercmd/mecatl-executor/serve.go-health-listen, storage-full errorscmd/mecaexec/main.go-file-timeout,storage-timeouterror classinternal/adapter/executioncontroller/executor_server.gohealthport, legacy-shape acceptanceinternal/executionenv/identity.goExecutorHealthPort,HealthListenFlaguser-docs/operating/mecak8s/native-execution.mdUser-facing change
File tool calls on an execution environment fail with a tool error after one minute of unresponsive storage instead of hanging; a full workspace reports "workspace storage is full". An environment whose
/workspacecannot be written becomes not ready.Special notes for reviewers
API compatibility: no protobuf change and no public wire API change. The private executor API returns
RESOURCE_EXHAUSTEDfor full storage where it previously returnedINTERNAL, and the client now sets a gRPC deadline on file calls; existing clients already treat these as ordinary errors. The new health service is on a separate port. Provider and executor ship from the same release, and a new provider with an older executor image never becomes ready.osfsreads and can exhaust the executor storage bound #2994: a FIFO in the workspace blocksosfsreads. Each such read now fails at the client deadline and leaves one stuck handler in the executor; other file calls keep working.osfsfile contents intact whenReplaceFileorCreateFilewrites fail #2992: a failedReplaceFileorCreateFilewrite can leave a truncated or empty file, which matters more now that a full volume stays ready.