Repository navigation
fix(orcad): a liveness probe must not mistake its own shell for orcad - #33158
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review.
|
There was a problem hiding this comment.
Actionable comments posted: 1

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
17b05690-8115-487b-b526-41ae24e9c31a
Files selected for processing: 2-
src/main/managed-server/install/orcad-remote-launch.test.tssrc/main/managed-server/install/orcad-remote-launch.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
-
There was a problem hiding this comment.
Actionable comments posted: 2

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
b3a94a59-379e-45dd-ad8b-85ffffb132a4
Files selected for processing: 2-
src/main/managed-server/install/orcad-remote-launch.test.tssrc/main/managed-server/install/orcad-remote-launch.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
-
| orcad.kill() | ||
| waiting.kill() |
There was a problem hiding this comment.
Terminate the waiting shell’s Node child.
The ; : command keeps the waiting shell alive while a separate Node process runs. waiting.kill() signals only the shell PID. The Node child can continue running after withSlot removes its temporary directory. Start the waiting shell in its own process group and terminate the group during cleanup.
After a host or distro restart the recorded orcad PID is free, and the probe's own 'sh -c' (whose argv carries the slot paths) can be given it. The argv identity check matched and kill -0 succeeded, so the probe answered LIVE: a wake skipped the start and the next probe found nothing. The probe now treats its own PID, or any shell process, as a reused PID.
…r shell Review: an older launcher (before exec) recorded a shell that waits on a live orcad, and the setsid launch path holds an sh between the PID write and exec; calling every shell reused turned those into DEAD, which permits GC and relaunch. Only the probe's own shell and the shell wrapping it are now excluded.
033e8a9 to
928a9c6
Compare
There was a problem hiding this comment.
🧹 Nitpick comments: 1
src/main/managed-server/install/orcad-remote-launch.test.ts: 1
152-152:Trivial · Maintainability & Code Quality · Quick win Keep the wrapper shell as the parent in the parent-PID test.
When the outer shell runs its final command, it can replace itself with that command. The inner
sh -cthen takes the recorded PID, so its$$equals the recorded value. TheDEADassertion can pass through the$$check alone. Removing the$PPIDcheck would not fail this test.Appending
; :makes the innersh -ca non-final command. The outer shell then stays alive as the inner shell's parent. The inner probe's$PPIDequals the recorded PID, so this test exercises the$PPIDguard.This is a test-coverage gap. The production probe already treats both
$$and$PPIDas reused PIDs, so this change does not fix a current production failure.Suggested fix
- `echo $$ > '${slot}/.orcad-pid'; sh -c ${JSON.stringify(probe).replace(/\$/g, '\\$')}` + `echo $$ > '${slot}/.orcad-pid'; sh -c ${JSON.stringify(probe).replace(/\$/g, '\\$')}; :`

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
bf84517d-4b56-40f6-885f-4f6cce9e0f38
Files selected for processing: 1-
src/main/managed-server/install/orcad-remote-launch.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
-
…exercised on dash
ELI5
To decide whether Orca's server on a remote machine is still running, Orca reads the process number it saved at launch and checks whether that process is alive. After the machine restarts, that number is free, and the shell running the check itself can be given it. The check then saw itself, decided the server was running, and didn't start it. The connection failed, and you had to try again. Now the check never counts itself, or any shell, as the server.
What Changed
orcadLivenessProbeCommandidentified orcad by PID plus argv: the process's arguments had to contain the slot's launcher or server path.sh -c '<script>', and the script itself contains those paths.ps -o args=matched andkill -0succeeded, so the answer was LIVE.orcad_reusedtreats a recorded PID as reused when it is the probe's own shell ($$), or the shell that wraps it ($PPID, as with an SSH orwsl.execommand wrapper). Everything else is unchanged, and Windows uses its own creation-time check.execwas added recorded a shell that waits on a live orcad.shbetween writing the PID andexec.Why
boot_iddoesn't change.Linked Issue
Internal: WSL via orcad D3 startup (a cold wake that needed a click); also affects managed SSH hosts after a reboot.
Visual Proof
N/A. This changes the remote liveness probe; the user-visible effect is that a reconnect after a host restart no longer fails with "recorded active but its process has exited".
Testing
I manually tested these changes locally: seen on a real Windows box (WSL 2.7.10, systemd distro) as an intermittent cold-start connect failure. The milestone logs showed the wake reading "serving" and the probe reading "exited" 0.4 s apart.
Automated tests added/updated:
orcad-remote-launch.test.tsnow runs the real probe insh.node <slot>/orcad.jsstill reads LIVE, and so does an older launcher's waiting shell.psfor the process's argv instead of sleeping.An independent review found a blocking issue in the first version, which also excluded every shell; it's fixed as described above.
Reproduced live in Docker. A fresh container stands in for a rebooted host, and its recorded PID is the one the next probe shell gets. The probe from main reads LIVE on both debian (dash) and alpine (busybox ash), and the probe from this PR reads DEAD on both.
The wrapped-shell case keeps its outer shell alive (
; :), so the$PPIDclause is exercised on dash as well, not only on bash 3.2. With that clause removed, the test fails.The older-launcher fixture now runs in its own process group, and cleanup kills the whole group, so no idle
nodechild is left behind after the test.PR checks, including both shards of
ssh on managed orcad (Docker), passed on the previous head.Review
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)