Skip to content

feat(executor): bound file calls and gate readiness on /workspace - #2995

Merged
blkt merged 1 commit into
mainfrom
feat/2698-storage-bounds
Nov 26, 2026
Merged

blkt merged 1 commit into
mainfrom
feat/2698-storage-bounds

Conversation

@blkt

@blkt blkt commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Stops file tool calls hanging on unavailable storage, makes executor readiness depend on /workspace being writable, and reports full storage as a clear tool error.

  • Every FileService call from executorclient.Workspace runs under a one-minute deadline (WithFileCallTimeout) covering whole streams. On expiry the tool gets 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. mecaexec gains -file-timeout.
  • ENOSPC and EDQUOT map to RESOURCE_EXHAUSTED ("workspace storage is full") instead of a generic INTERNAL, injected through fileserver.WithStorageFullErrors because depguard keeps syscall out of internal/executorrpc.
  • mecatl-executor serve -health-listen serves plaintext grpc.health.v1, reporting SERVING only while /workspace accepts a new file within 30 seconds (checked every 2 seconds, unnamed O_TMPFILE on Linux). A stuck check is abandoned and not repeated until it returns. A full volume (ENOSPC, EDQUOT) or a /workspace the agent made read-only (EACCES, EPERM) stays ready, so the agent can fix it.
  • New executor Pods get -health-listen=:7444, a health port, 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

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Dependency update
  • Documentation
  • Other (describe):

Test plan

Baseline checks

  • Linting (task lint)
  • Fast offline test suite (task test): left to CI
  • Pre-review race suite (task test:race): left to CI; focused -race runs pass for internal/executorrpc/..., internal/executionexecutor, internal/executionenv, internal/adapter/executioncontroller, internal/adapter/executionclient/..., cmd/mecatl-executor and cmd/mecaexec
  • Offline demo (go run ./cmd/mecademo)
  • Markdown changed: docs generation/link checks (task docs)
  • User docs/user-facing behavior changed: site build (task site:build)
  • Guarded engine API affected: compatibility check (task api:check)
  • Intentional engine API change: task api:update + engine/CHANGELOG.md

Also: go vet with every build tag on Linux and darwin (only the known darwin e2e Pdeathsig failure, also on main). New tests cover a FileService that never answers (unary, server-stream after one chunk, client-stream) failing with ErrStorageTimeout after the bound, the caller's own deadline and cancellation still reported as such, fstools.WriteTool failing on a hung call and on ENOSPC/EDQUOT, health going NOT_SERVING when /workspace is removed or not writable, and the drift check for new, legacy and mixed Pod shapes. The O_TMPFILE path was run in a Linux container. The Kind production qualification passed in CI on an earlier head with the same readiness probe.

Changes

File Change
internal/executorrpc/executorclient/client.go, workspace.go Per-call deadline, ErrStorageTimeout, error classification
internal/executorrpc/fileserver/server.go WithStorageFullErrors → RESOURCE_EXHAUSTED
internal/executionexecutor/workspace_health*.go, workspace_touch_*.go /workspace health checker
cmd/mecatl-executor/serve.go Health server, -health-listen, storage-full errors
cmd/mecaexec/main.go -file-timeout, storage-timeout error class
internal/adapter/executioncontroller/executor_server.go gRPC readiness probe, health port, legacy-shape acceptance
internal/executionenv/identity.go ExecutorHealthPort, HealthListenFlag
user-docs/operating/mecak8s/native-execution.md Readiness port and storage-failure troubleshooting

User-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 /workspace cannot 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_EXHAUSTED for full storage where it previously returned INTERNAL, 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.

@blkt blkt self-assigned this Nov 26, 2026
@blkt
blkt force-pushed the feat/2698-storage-bounds branch from 6d0cc1c to ab1c422 Compare November 26, 2026 09:48
@blkt
blkt force-pushed the feat/2698-storage-bounds branch 2 times, most recently from 562cc6f to d052625 Compare November 26, 2026 14:15
@blkt
blkt force-pushed the feat/2698-storage-bounds branch from d052625 to b1cfb12 Compare November 26, 2026 15:17
@blkt blkt changed the title feat(executor): bound storage waits and gate readiness on /workspace feat(executor): bound file calls and gate readiness on /workspace Nov 26, 2026
@blkt
blkt marked this pull request as ready for review November 26, 2026 15:26

@rdimitrov rdimitrov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 -race tests for executorrpc/..., executionexecutor, executionenv, executioncontroller, executionclient, cmd/mecatl-executor, and cmd/mecaexec: all pass.
  • executor:smoke passes. I then ran the image with -health-listen=:7444 on a 2 MiB tmpfs /workspace, which exercises the Linux O_TMPFILE path:
    • the server, FileService, and CommandService all report SERVING, and an unknown service returns NotFound;
    • when the volume is full, mecaexec create fails with ResourceExhausted: workspace storage is full, health stays SERVING, and the create works again once space is freed;
    • after mkfifo p, mecaexec -file-timeout 3s read p returns class: storage-timeout after 3s, and other file calls keep working.
  • 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.

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
@blkt
blkt force-pushed the feat/2698-storage-bounds branch from 813a8f0 to ca15d29 Compare November 26, 2026 19:38
@blkt
blkt enabled auto-merge (squash) November 26, 2026 19:41
@blkt
blkt merged commit 029c818 into main Nov 26, 2026
48 checks passed
@blkt
blkt deleted the feat/2698-storage-bounds branch November 26, 2026 20:04

This branch was successfully deployed

1 active deployment
Preview — ca15d29c Deployed Nov 26, 2026 by vercel[bot]
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.

Bounded storage waits and /workspace readiness

2 participants