Skip to content

fix(managed-server): snapshot capture and restore run on BusyBox before 1.30 - #30840

Merged
nwparker merged 1 commit into
mainfrom
nwparker/snapshot-busybox-timeout
Oct 19, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/snapshot-busybox-timeout

Conversation

@nwparker

@nwparker nwparker commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​20 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​20
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2

ELI5

Before Orca updates its server on an SSH host, it saves a snapshot of the server's state so it can roll back. On hosts with an old BusyBox (before 1.30), the snapshot command never actually ran, so every update stopped the server, failed with "Could not snapshot...", and restarted it. Now the snapshot works there too.

What Changed

Before: the state-mutation wrapper (used by snapshot capture, restore and clear) ran timeout -s KILL 900 sh -c …. BusyBox before 1.30 only accepts timeout [-t SECS] [-s SIG] PROG, so it treated 900 as the program to run and exited 127. The script never ran. The wrapper printed no verdict, and parseOrcadSnapshotCapture read that as failed with no reason.

After: the wrapper probes which syntax the host's timeout takes, the same way the snapshot room check from #30618 already does:

  • modern timeout -s KILL 900;
  • otherwise timeout -t 900 -s KILL;
  • otherwise no deadline, as before when timeout was missing.

Why

This matches the probe that orcad-state-snapshot-space.ts already uses for the same BusyBox, so the two commands now agree about the host. When #30744 rewrote this line, it kept the old syntax.

Alternatives considered:

  • Dropping the deadline would lose the kill on a hung tar.
  • Shipping our own timeout would be far more code than one more probe branch.

Linked Issue

Post-hardening scan finding; follow-up to #30618 and #30744.

Visual Proof

N/A: the change is a remote shell command, with no UI.

Testing

  • New real-shell test in orcad-state-snapshot-shell.test.ts. It puts an old-BusyBox-style timeout stub first on PATH (it accepts only -t SECS [-s SIG] PROG). On main the capture parses as failed; with the fix it parses as captured.
  • src/main/managed-server/host-state (single worker): 110 passed.
  • Full static job locally: clean.
  • Not verified on a real BusyBox host; stub-based test only.

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • POSIX hosts only. Windows hosts use a separate path.
  • No wire change.
  • The command grows by about 60 bytes, inside the gateway exec budget tests.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…re 1.30

The state mutation wrapper ran `timeout -s KILL 900 sh -c ...`, which old
BusyBox (`timeout [-t SECS] [-s SIG] PROG`) reads as running a program
named 900. The script never ran, the capture answered nothing and parsed
as failed, so every update stopped the server and rolled back. Probe the
syntax as the room check (#30618) already does.

Co-Authored-By: Claude <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

The POSIX mutation command probes standard timeout syntax, then BusyBox’s -t syntax, and applies the configured deadline with the first supported form. A new shell test uses a mock timeout that accepts only -t and verifies that snapshot capture parses as captured.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to 8e4a6

A host without an executable true can run snapshot, restore, or clear mutations without the configured timeout, and the new test would not catch that omission. This is a bounded environment-specific concern; merge with owner awareness or follow-up.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly identifies the main change: fixing snapshot capture and restore on older BusyBox versions. It is concise and specific.
Description check Passed The description is mostly complete. It explains the problem, changed behavior, rationale, testing, scope, and compatibility impact. It includes issue references, although it does not use the template'…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description is mostly complete. It explains the problem, changed behavior, rationale, testing, scope, and compatibility impact. It includes issue references, although it does not use the template's explicit “Fixes #” format, and the final CI checklist remains unchecked.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Git: CodeRabbit could not clone the repository, so clone-backed analysis was skipped and this review may be incomplete. Verify repository clone access, such as SSH credentials, before requesting another full review. If clone access is intentionally unavailable, use path_filters to narrow the review scope.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments: 1
src/main/managed-server/host-state/orcad-state-snapshot-shell.test.ts: 1

129-135: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert the mutation timeout arguments.

The shim validates only the -t syntax and then executes the command. If orca_deadline is empty, the capture command still runs and returns captured. Record shim invocations and assert that the mutation invocation contains -t 900 -s KILL, separately from the one-second probe.


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3df12a48-2426-4407-843b-b126f1ca101d
📥 Commits

Reviewing files that changed from the base of the PR and between dd85af1 and 8e4a62b.

📒 Files selected for processing: 2
  • src/main/managed-server/host-state/orcad-state-snapshot-shell.test.ts
  • src/main/managed-server/host-state/orcad-state-snapshot.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

Comment on lines +139 to +140
`orca_deadline=; if timeout 1 true 2>/dev/null; then orca_deadline="timeout -s KILL ${ORCAD_STATE_MUTATION_DEADLINE_SECONDS}";`,
`elif timeout -t 1 true 2>/dev/null; then orca_deadline="timeout -t ${ORCAD_STATE_MUTATION_DEADLINE_SECONDS} -s KILL"; fi;`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

set -eu
printf '%s\n' '--- changed file ---'
nl -ba src/main/managed-server/host-state/orcad-state-snapshot.ts | sed -n '1,240p'
printf '%s\n' '--- related timeout probes and callers ---'
rg -n -F --glob '*.{ts,tsx}' -e 'timeout 1 true' -e 'timeout -t 1 true' -e 'sh -c :' -e 'orca_deadline' -e 'ORCAD_STATE_MUTATION_DEADLINE_SECONDS' src

Repository: stablyai/orca

Length of output: 15385


🏁 Script executed:

set -eu
printf '%s\n' '--- changed file ---'
nl -ba src/main/managed-server/host-state/orcad-state-snapshot.ts | sed -n '1,240p'
printf '%s\n' '--- related timeout probes and callers ---'
rg -n -F --glob '*.{ts,tsx}' -e 'timeout 1 true' -e 'timeout -t 1 true' -e 'sh -c :' -e 'orca_deadline' -e 'ORCAD_STATE_MUTATION_DEADLINE_SECONDS' src || test "$?" -eq 1

Repository: stablyai/orca

Length of output: 15385


Probe timeout with the shell that runs the mutation.

If true is available only as a shell builtin, timeout cannot execute it. Both probes can fail, leaving orca_deadline empty even when timeout is installed. Use sh -c :, which the mutation already requires.

🐛 Suggested fix
--- "a/src/main/managed-server/host-state/orcad-state-snapshot.ts"
+++ "b/src/main/managed-server/host-state/orcad-state-snapshot.ts"
@@ -136,8 +136,8 @@
     // Why timeout inside the group: KILL then reaches tar and rm, not only the shell.
     // The deadline is a word list, so the script is sent once, not once per branch.
     // BusyBox before 1.30 spells it `timeout -t SECS`, as the room probe found.
-    `orca_deadline=; if timeout 1 true 2>/dev/null; then orca_deadline="timeout -s KILL ${ORCAD_STATE_MUTATION_DEADLINE_SECONDS}";`,
-    `elif timeout -t 1 true 2>/dev/null; then orca_deadline="timeout -t ${ORCAD_STATE_MUTATION_DEADLINE_SECONDS} -s KILL"; fi;`,
+    `orca_deadline=; if timeout 1 sh -c : 2>/dev/null; then orca_deadline="timeout -s KILL ${ORCAD_STATE_MUTATION_DEADLINE_SECONDS}";`,
+    `elif timeout -t 1 sh -c : 2>/dev/null; then orca_deadline="timeout -t ${ORCAD_STATE_MUTATION_DEADLINE_SECONDS} -s KILL"; fi;`,
     `orca_state_group $orca_deadline ${run};`,
     `status=$?; ${owned ? `[ "$status" -eq ${ORCAD_FENCE_LOST_EXIT} ] && exit ${ORCAD_FENCE_LOST_EXIT}; ` : ''}if [ "$status" -eq 124 ] || [ "$status" -eq 137 ]; then echo ${ORCAD_STATE_MUTATION_DEADLINE}; fi`
   ].join(' ')
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
`orca_deadline=; if timeout 1 true 2>/dev/null; then orca_deadline="timeout -s KILL ${ORCAD_STATE_MUTATION_DEADLINE_SECONDS}";`,
`elif timeout -t 1 true 2>/dev/null; then orca_deadline="timeout -t ${ORCAD_STATE_MUTATION_DEADLINE_SECONDS} -s KILL"; fi;`,
`orca_deadline=; if timeout 1 sh -c : 2>/dev/null; then orca_deadline="timeout -s KILL ${ORCAD_STATE_MUTATION_DEADLINE_SECONDS}";`,
`elif timeout -t 1 sh -c : 2>/dev/null; then orca_deadline="timeout -t ${ORCAD_STATE_MUTATION_DEADLINE_SECONDS} -s KILL"; fi;`,

@nwparker
nwparker merged commit 2b07f0f into main Oct 19, 2026
52 checks passed
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