Repository navigation
Improvements for devbox robustness - #4775
michaeljguarino wants to merge 28 commits into
Conversation
|
plural deploy this (and set kas to the same sha tag) |
There was a problem hiding this comment.
Deployment PR created: https://github.com/pluralsh/plrl-up-demos/pull/3903 — Console and KAS are both pinned to sha-751479c.
Confidence Score: 4/5
[Medium impact] The changes reach devbox lifecycle, Console state, runner capacity, and several API workflows. Fix the reset-confirmation race before merging; it can leave restored thread updates permanently missing. Findings
SummaryImproves devbox crash recovery, resume reporting, capacity tracking, and memory limits.
Reviews (3) · Last reviewed commit: "Leave instances still being adopted to a..." · Reviewed by Greptile |
751479c to
c2f26dc
Compare
|
plural deploy this (and set the kubernetes-agent, kas, tag to the same sha) |
There was a problem hiding this comment.
Deployment PR created: https://github.com/pluralsh/plrl-up-demos/pull/3907 — Console, kubernetes-agent, and KAS are pinned to sha-c2f26dc.
|
plural deploy this (and set kas to the same img tag) |
There was a problem hiding this comment.
GitOps deployment PR has been created: https://github.com/pluralsh/plrl-up-demos/pull/3913
Console and KAS are both pinned to sha-3d0ecd0.
|
plural deploy this (and set the kas image too) |
There was a problem hiding this comment.
Follow-up: https://github.com/pluralsh/plrl-up-demos/pull/3914 updates both Console and KAS to sha-1991579 from this source PR head.
|
plural deploy this |
There was a problem hiding this comment.
Deployment promotion created: https://github.com/pluralsh/plrl-up-demos/pull/3917
This pins the Console image to sha-ad665e3 and is annotated for mgmt/apps reconciliation.
* Proper crash detection * handle some grpc edge cases
* gateway: push every box's deltas in one PushInstanceDeltas per 200ms rather
than one per box every 50ms, cutting the unary calls KAS proxies
* gateway: report a wake to console as provisioning ("resuming"), and a failed
one as suspended with its error, so viewer pings and resume_if_suspended
calls stop re-requesting resumes during a slow or failed wake
* console: debounce ping-driven resumes (resume_requested_at, 2 minutes) and
allow provisioning -> suspended; show "Resuming…" in the UI
* actors: record demand for every instance waiting for room, zoned or not,
and wait out ReadyTimeout instead of giving up after a minute
* operator: count zoneless demand for the single pool, add
spareInstancesPercent (default 10) and raise the spareInstances floor to 2,
and watch the demand ConfigMaps so scale-up starts within seconds
* kas: cache positive tunnel lookups per cluster for 5s instead of a Redis
scan on every control call
* ui: list an option marked "(Recommended)" first in question forms
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A box killed for exceeding its memory limit is reverted, and the daemon expires every pending interaction: the agent process waiting on the reply is gone. The question used to vanish with it. * console: answering an expired interaction sends the answer to its thread as a new prompt (waking the box if needed), naming the question and the choice, and records it as answered under the row's lock; a subagent's goes to the thread that started it * ingest: a replayed expiry never downgrades an answered interaction * ui: expired requests keep their form or approval buttons with a note that the answer goes to the thread; expired approvals and subagent requests get a card too Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A box that fills its memory is killed on the host and reverted to its last snapshot, losing running turns, background jobs and unanswered questions: nothing inside the guest pushed back first. The daemon now builds a cgroup tree at boot (as root, through `sudo devbox-daemon cgroup-setup`): itself in devbox/daemon, and a devbox/workload group capped at 88% of the guest's memory, with leaves for agent CLIs, terminals, the browser and Docker containers. Processes start directly in their leaf (clone3 CLONE_INTO_CGROUP), so every command a harness forks is capped without the harness knowing about cgroups. At the cap the kernel reclaims page cache and then kills the largest process, not the box. There's no memory.high: without swap, anonymous memory above it can't be reclaimed and the kernel throttles instead of killing, which stalled a test allocator indefinitely. Verified in a live box: a 1.5 GB allocator under a 512 MiB cap was killed within a second, the daemon and box unaffected. * dockerd gets --cgroup-parent when the tree exists * AGENTS.md's resources section names heavy jobs, says to run them one at a time, and states the cap and what hitting it does * set up only when the daemon is PID 1; any failure leaves the box uncapped as before (DEVBOX_NO_WORKLOAD_CAP opts out) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude-agent-acp sends an AskUserQuestion with multiSelect as an array property whose items list the choices (anyOf). The interaction card only read enum and oneOf, so these questions rendered as an empty text box. They're now checkboxes, recommended choice first, submitted as a list, with required, minItems and maxItems checked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* TestDeltasOfEveryBoxShareOnePush wrote to the second instance's forwarder before it existed: running() returns once the instance is RUNNING (set just before its forwarder starts) and once any forwarder subscribed, which the first instance's already satisfies. Wait for both forwarders. * make sync in js/documentation for spareInstancesPercent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
The AI cron analyzes stale services once Service.stable/1 lets them through (10 minutes after their last update). A service its cluster never synced has no component_status yet, and Evidence.Service.changed?/1 split it as a string: String.split(nil, "/") crashed the memoizer task (FunctionClauseError), e.g. for new bootstrap services on a cluster whose agent hadn't connected. Latent since #3526. * changed?/1 only parses a string component_status; nil or an unparseable one counts as changed, so the service is analyzed (why isn't it syncing?) * service, cluster and service-component evidence no longer error-log {:ok, nil} from a component insight: that's Memoizer's "nothing to analyze" Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A user invoking a PR automation whose regex was `(image: (.*)` got
"unknown error": pull requests apply the automation's regexes with Go's RE2
in `plural pr template`, the failure came back as the CLI's output
(%Tee{}), and the REST fallback controller turned anything that wasn't a
string, atom or changeset into a bare "unknown error". The automation
itself had been accepted, so every pull request it created would fail.
* REST: the fallback describes errors the way the GraphQL error handler
does (now ErrorHandler.message/1), so a failed template returns the CLI's
message, without color codes
* console: saving a PR automation validates updates.regexes, updates.files
and regex_replacements[].regex: they must compile, and PCRE-only syntax
RE2 rejects (lookarounds, atomic groups, backreferences) is refused; a
templated regex with template markers is left to pull request time
* CRD: CEL rules compile the same fields with RE2 (CEL's matches), so an
invalid PrAutomation is rejected on apply. The rules use 'a' rather than
'' for the probe string: gofmt rewrites '' in doc comments to a curly
quote, which would break them. Verified against envtest 1.28.3 and 1.35.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* drop the console-side changeset validation: `plural pr template` now
validates every regex up front with Go's RE2 (pluralsh/plural-cli),
and its error reaches API callers through the fallback controller
* CRD rules read as what they check, type('a'.matches(r)) == bool: CEL has
no "valid regex" function, and matches errors on a pattern that doesn't
compile, which rejects the resource
* the CRD skips patterns with template markers wherever the CLI renders
them first: regexReplacements[].regex (the CLI templates it whatever
`templated` says) and files; regexes aren't templated, so always checked
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The cause of the user report: a PR automation's configuration field had
validation regex `(image: (.*)`. Pr.Validation matched inputs with
~r/#{r}/, and interpolating into the sigil compiles at runtime with
Regex.compile!, which raised Regex.CompileError inside createPullRequest.
safe_resolver rescued it, and Console.GraphQl.Exception's fallback for an
unknown exception is "unknown error (check the logs for more details)".
Reproduced in a test against the old code before fixing it.
* Pr.Validation compiles the pattern with Regex.compile and returns an error
naming the field, the pattern and why it's invalid
* Configuration rejects a validation regex that doesn't compile on save, so
a new automation can't hold one (console evaluates this regex itself, with
Elixir's engine, so this is the right place to check it)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The health loop adopts an actor running under a suspended instance once it has been seen running for a HealthInterval, timed from the first check that saw that state. The test made exactly one pass after advancing the clock, so a background actor check that read the actor before it woke, applied late, restarted that timer and the pass rightly declined to adopt: "timed out waiting for running" in CI. Reproduced by injecting such a late check. It now passes once per interval until the actor is adopted, as the live loop does, still after asserting one sighting isn't enough. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Greptile: if console took the "resuming" report but missed every retry of the failure report, it stayed at provisioning/"resuming" for good. Heartbeats don't carry the status, the health loop saw the actor correctly suspended, and an explicit resume of a "resuming" instance answers without reaching the gateway, so the user couldn't recover. reportSuspended keeps a report console didn't acknowledge pending, and the health loop resends it each pass (retryReport, like retryReset) until console takes it. A newer status supersedes it, and it keeps its generation, so a late resend can't undo a newer status. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
master (#4770) retries adoption until Substrate answers and marks the instance adopting until it has seen the actor, keeping backstops and Suspend/Resume away from it meanwhile. The health loop reconciled records with actors without regard to that, so it could act on a just-loaded instance whose record is stale. healthPass and checkActor now skip an adopting instance, as the other backstops do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
53288a1 to
33a8497
Compare
|
plural deploy this |
| if !g.report(ctx, req) { | ||
| return false | ||
| } | ||
| inst.mu.Lock() | ||
| if inst.reverts == reverts { | ||
| inst.rec.IndexReset = false |
There was a problem hiding this comment.
Skipped resets lose restored updates
resetIndexLocked can clear IndexReset even though console skipped the reset. While retryReset sends generation N, a concurrent resume can report RUNNING with generation N+1. If N arrives later, console treats it as stale and returns success without resetting anything.
g.report treats that reply as confirmation and clears the flag. The forwarder then sends and acknowledges restored events that console drops because their revisions are too low. Keep the reset pending until console confirms it actually applied, or serialize reset reports with status reports.
There was a problem hiding this comment.
Deployment GitOps PR created: https://github.com/pluralsh/plrl-up-demos/pull/3922 — it updates the Console main image to sha-33a8497 and is annotated for Plural Service: mgmt/apps.
A user's service failed with "error preparing kustomize overlay: lstat /tmp/manifestsXXXX/kustomize-postrender: no such file or directory" for one chart while the same setup worked for another. The agent reads the overlay (and luaFile/luaFolder) from the service tarball's root, but for a chart from a helm repository (or another git repository) Services.tarstream only splices in part of the service's own repository: * with luaScript, all of it (so the overlay came along by accident) * with valuesFiles, only those files: the overlay was dropped * otherwise, nothing: the chart alone tarstream now also splices in the post-render overlay, the lua folder and the lua file from the service's repository, with or without values files (folder names normalized, "." meaning the whole repository). The digest also keeps the repository when a post-render overlay is set, so editing the overlay in git redeploys the service. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It waited a fixed 3s and then required two reconciles, which DeQueueJitter
(1s) spaces apart; on a loaded CI runner that budget ran out ("Should be
true" at controller_supervisor_test.go:90). Wait for the two reconciles with
assert.Eventually and a generous deadline instead.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The fork's plural/main branch is upstream main plus the privileged actor, RootfsUpperDisks and BLOCK external volume patches. Sync the CRDs, Envoy configs and SandboxConfigs from it, and mirror upstream's automountServiceAccountToken: false on atenet-egress and rustfs. The microvm SandboxConfig now pins a rootfs-upper-disk asset that atelet fetches on every node, so microvm-assets embeds Substrate's upper-disk.ext4.zst and stages it with the Kata and Cloud Hypervisor assets. It stays optional for SandboxConfigs that don't pin it. Co-authored-by: Cursor <cursoragent@cursor.com>
|
plural deploy this |
There was a problem hiding this comment.
Deployment PR created: https://github.com/pluralsh/plrl-up-demos/pull/3928
It pins the demo Console image to sha-eff9ca7 and is annotated for Plural Service: mgmt/apps.
A DevboxRunner can set home.volumeMode: Block (microvm pools on Block storage only). The operator then asks Substrate for a BLOCK external volume, which ateworker-microvm attaches as a virtio-blk disk, so home writes go through the guest's page cache instead of virtiofsd's. devbox-disk-prep creates device-mapper slots (ate-blk-<n>) that Substrate grants to microVM workers with /dev/kvm. --block-slots=auto sizes them to the node's CSI attach limit, so slots never run out before attachments do. devbox-block publishes a home by loading the CSI device into a free slot and resets the slot on unpublish. Runners that don't set volumeMode keep filesystem homes, and existing instances keep their revision. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
The docs check ran in the test job that build-image needs, so a stale api.md held up the image. It is now its own job, and it also checks the docs site's copy. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com> # Conflicts: # go/deployment-operator/pkg/devbox/gateway/tunnel/tunnel.go
3bd75d9 to
21d8876
Compare
|
plural deploy this |
There was a problem hiding this comment.
Deployment requested and acknowledged. GitOps promotion: https://github.com/pluralsh/plrl-up-demos/pull/3946 (Console image tag sha-9a69a78; Plural Service: mgmt/apps).
KAS load & capacity
KAS CPU spiked with 20–30 devboxes active on one runner, and users were disrupted while the worker pool caught up.
PushInstanceDeltasper 200ms. Before, each box sent its own every 50ms, so at about 25 active agents KAS proxied roughly 500 unary calls a second.provisioning("resuming"), and a failed wake assuspendedwith its error. Viewer pings andresume_if_suspendedcalls stop re-requesting resumes while a wake is slow or failing. Console also debounces ping-driven resumes (resume_requested_at, 2 minutes). The UI shows "Resuming…".ReadyTimeoutinstead of giving up after a minute. The operator counts zoneless demand for single-pool runners and watches the demand ConfigMaps, so scale-up starts within seconds. NewspareInstancesPercent(default 10%), and thespareInstancesfloor is raised to 2.Note: atenet-router calls
ResumeActoron every routed request, even to running actors. That's in Substrate and isn't changed here.Questions and approvals survive crashes
A box killed for exceeding its memory limit is reverted, and its pending questions and approvals expired with nobody told.
(Recommended)option first, and multi-select questions render as checkboxes instead of an empty text box.Memory cap inside the box
The daemon builds a cgroup tree at boot, via
sudo devbox-daemon cgroup-setup. The daemon sits indevbox/daemon, anddevbox/workloadis capped at 88% of guest RAM, with leaves for agent CLIs, terminals, the browser and Docker (--cgroup-parent). Processes start directly in their leaf (clone3withCLONE_INTO_CGROUP), so every command a harness forks is capped without the harness knowing. At the cap the kernel reclaims page cache, then kills the largest process instead of the box being OOM-killed and reverted.memory.high. Without swap it throttled a test allocator indefinitely instead of killing it.DEVBOX_NO_WORKLOAD_CAPopts out.Test Plan
cgrouppackage (Prepareagainst a fake cgroupfs, delegation, fallback paths). All daemon packages pass exceptdaemon/proc'sTestDeprioritizeLowersAProcess, which this PR doesn't touch.devboxes_test,devboxes/ingest_testanddevboxes/threads_testpass: 136 tests, covering the resume debounce,provisioning → suspended, late answers to expired questions and approvals (including a subagent's), and replay protection.DevboxInteractionCardanddevboxIdletests (expired cards, recommended-first, multi-select, "Resuming…"); biome, oxlint andtsc --buildare clean.devstarted a process directly in the leaf, and a 1.5 GB allocator was killed in under a second while the daemon and box were unaffected (memory.eventsrecorded oneoom_kill). The box's cgroups were restored afterwards.Test environment: https://console.plrldemo.onplural.sh/cd/clusters/1fb8bed1-20a9-4ddd-b5f8-5a68f314cc79/services/501cb8b2-3ce2-440b-93d7-722e5929295d/components
Checklist
Plural Flow: console
🤖 Generated with Claude Code