Skip to content

feat(sbx): SBX_WORKER_AT_BOOT=0 installs a worker without enabling it for boot - #799

Merged
webchang merged 3 commits into
rossoctl:mainfrom
webchang:fix/796-worker-at-boot
Nov 13, 2026
Merged

webchang merged 3 commits into
rossoctl:mainfrom
webchang:fix/796-worker-at-boot

Conversation

@webchang

Copy link
Copy Markdown
Member

Closes #796. One signed-off commit on main (86d6350), in deploy/sbx only.

What it does: install-host.sh takes a new setting, SBX_WORKER_AT_BOOT, so that on a host run by a host agent, a boot doesn't start every installed template worker.

  • 1 (the default): the worker's unit is enabled for boot, as today. Nothing changes for an existing install.
  • 0: the unit is installed and started once, as today, but left disabled. A boot then starts none of the workers, and the host agent starts each one from the control plane's wanted state.
  • Every re-install applies the value it's given: a re-install with 0 disables a unit an earlier install enabled, and one with 1 enables it again.
  • Only the enable line changes: systemctl enable becomes systemctl disable under 0. reset-failed, the single restart and the attach wait are as before.
  • Validation: only 0 or 1 is accepted. Anything else is refused, naming the value, before any systemctl call or file write. An empty value is refused, unlike the other settings, so a mistaken empty pass never silently means boot starts. Only an unset variable defaults to 1.
  • The docs: deploy/sbx/README.md §2 describes the setting, and RUNBOOK step 5 says to use SBX_WORKER_AT_BOOT=0 on a host run by a host agent.

Why: on a host-agent host, a reboot started every installed worker at once, and the agent stopped them about 20 s later. That wastes cold starts, and a stop during a worker's pool fill can leak a VM (#795).

Not in this PR: the host agent itself isn't on main yet. Its install should pass SBX_WORKER_AT_BOOT=0, which is a one-line follow-up in the host-agent PR (#772) once this is in.

Tests (deploy/sbx/tests/install-host.test.sh):

  • the systemctl mock now tracks each unit's enable state;
  • new cases: the default enables and never disables; 2, yes, '', ' 1' and 01 are each refused before any systemctl call or env file write; a fresh install with 0 starts once without enabling; a re-install takes 1 → 0 → 1 through disable and enable again. They fail on the unmodified script;
  • bash 5: 42 ok (main: 39). With bash 3.2 first on the PATH, the file stops at the existing janitor case (declare -A), as on main, after the three new cases pass;
  • shellcheck adds no findings, and make test-deploy passes.

Expected overlaps: #782 and #757 also change install-host.sh (the read-ahead unit, the legacy jail), so whichever merges later rebases a few lines.

Assisted-By: Claude Code

… for boot

install-host.sh enables every template worker unit it installs, and the
unit is WantedBy=multi-user.target, so a host boot starts every installed
worker. Under a host agent, which starts and stops workers from the
control plane's wanted state, the agent's first run after a boot stops
all the workers nothing leases. Each of those starts pays a snapshot
verify and a standby pool fill for nothing, and a stop during a pool
fill can leak a VM (rossoctl#795).

install-host.sh now takes SBX_WORKER_AT_BOOT (0 or 1, default 1, so
nothing changes for existing installs). With 0 the unit is installed
and started once, as before, but disabled rather than enabled. Every
re-install applies the value it is given, so a re-install with 0
disables a unit an earlier install enabled, and one with 1 enables it
again. Any other value, an explicit empty one included, is refused
before systemd or any file is touched, as the script's other settings
are.

The README and the RUNBOOK say to use SBX_WORKER_AT_BOOT=0 on a host run
by a host agent. The tests cover the default, 0 on a fresh install, a
re-install with 0 then 1, and the refusals.

Refs rossoctl#796

Signed-off-by: Rong Chang <[email protected]>

@ingpaolodettori-dev ingpaolodettori-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Summary

Adds SBX_WORKER_AT_BOOT (0|1, default 1) to deploy/sbx/install-host.sh. Under 0 the worker unit is installed and started once but systemctl disabled, so a host boot leaves starting workers to the host agent (#796). I read every changed line. The default path is unchanged: still enable, then reset-failed and one restart. A re-install applies the value it is given, and disable on an already-disabled unit is a no-op. The ^[01]$ check runs before install_egress/install_units/install_worker, so a bad value touches nothing. The no-colon ${SBX_WORKER_AT_BOOT=1} correctly refuses an explicit empty value. [email protected] has [Install] WantedBy=multi-user.target and nothing else pulls the instances in at boot, and moca-egress stays enabled as before. The tests track enable state in the mock and cover the default, five bad values, a fresh 0, and 1 → 0 → 1 re-installs. The README and RUNBOOK match the behaviour. No issues found.

Author: webchang (MEMBER — maintainer)
Areas reviewed: Shell, Docs, Tests
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, all signed-off: yes
CI status: passing (all 16 checks green, including deploy-scripts, deploy-scripts-bash32 and shellcheck)

AI-assisted review, approved by a maintainer before posting.

@clawgenti clawgenti left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All checks pass. Ready for human review.

The validation runs before validate_worker, so any systemctl call or file write comes after it. It sits after the --egress early return, so it applies only to a worker install, which is the only path that reads it. Using ${SBX_WORKER_AT_BOOT=1} without the colon means an explicit empty value is refused, as the PR body says. disable on a unit that was never enabled is harmless, so a fresh install with 0 is safe. No inline comments.

  • Author: webchang (MEMBER — maintainer)
  • Areas reviewed: Shell (install-host.sh), tests (install-host.test.sh and the systemctl mock's enable state), docs (README §2, RUNBOOK step 5)
  • Agent/IDE config (.claude/.vscode): none
  • Commits: 1 commit, all signed-off: yes
  • CI status: passing (all 16 checks green, including deploy-scripts, deploy-scripts-bash32 and shellcheck). Mergeable (CLEAN).

Verified by:

  • bash deploy/sbx/tests/install-host.test.sh on the PR head: 42 ok, exit 0, including the four new SBX_WORKER_AT_BOOT cases
  • shellcheck 0.11 over deploy/sbx/*.sh and the test, diffed against main: no new findings
  • git merge-tree origin/main pr-799: clean. Against #800 it conflicts, as the PR body expects
  • grepped deploy/ for anything that reads a unit's enable state (is-enabled, list-unit-files, status.sh): only is-active is used, so nothing else depends on the change

Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).

@pdettori

Copy link
Copy Markdown
Member

need rebase and resolve conflicts

Conflicts in RUNBOOK.md and install-host.sh: main's guest-RAM, budget and SBX_WORKER_BIN text and setting, plus this branch's SBX_WORKER_AT_BOOT setting and RUNBOOK sentence. Both sides kept.

Refs rossoctl#796

Signed-off-by: Rong Chang <[email protected]>

@ingpaolodettori-dev ingpaolodettori-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Follow-up at 89cd353 (merge of main 634781a). Both conflict resolutions (install-host.sh defaults, RUNBOOK step 5) keep both sides. SBX_WORKER_AT_BOOT validation still precedes validate_worker and every write or systemctl call. CI is green and the PR is mergeable. No new issues.

AI-assisted review, approved by a maintainer before posting.

@pdettori

Copy link
Copy Markdown
Member

still conflicts

Conflicts in deploy/sbx/tests/install-host.test.sh, both sides kept: main's EXIT trap (it also ends the
reaper tests' leftover processes) with this branch's MOCK_ENABLED_DIR, and this branch's SBX_WORKER_AT_BOOT
tests followed by main's VM-reaper tests.

Refs rossoctl#796

Signed-off-by: Rong Chang <[email protected]>

@ingpaolodettori-dev ingpaolodettori-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Follow-up at c6cecd2 (merge of main 1016d26). The one hand resolution, in deploy/sbx/tests/install-host.test.sh, keeps both sides: main's EXIT trap (with the reaper-process cleanup) plus this branch's MOCK_ENABLED_DIR, and the SBX_WORKER_AT_BOOT tests followed by main's #795 reaper tests. Nothing was dropped (checked with git show --remerge-diff). The ^[01]$ check still runs before validate_worker (which now includes the SBX_LIBEXEC_DIR checks), so a bad value is refused before any write or systemctl call. A worker disabled with 0 still gets the ExecStopPost= reaper when it is stopped. No new issues.

Author: webchang (MEMBER — maintainer)
Areas reviewed: Shell tests (merge resolution)
Agent/IDE config (.claude/.vscode): none
Commits: 3 commits, all signed-off: yes
CI status: see checks

AI-assisted review, approved by a maintainer before posting.

@webchang
webchang merged commit 949dc5f into rossoctl:main Nov 13, 2026
16 checks passed
webchang added a commit to webchang/moca that referenced this pull request Nov 13, 2026
Upstream main (949dc5f) adds SBX_WORKER_AT_BOOT (rossoctl#799), the worker
stop's VM reap (rossoctl#800), and template tags, edits and owner transfer
(rossoctl#774). This branch claims no API version.

Conflicted:
- deploy/sbx/install-host.sh (main): both checks kept, this branch's
  SBX_READ_AHEAD_KB refusal and then main's SBX_WORKER_AT_BOOT one,
  each before the host is touched.

Also changed in the merge:
- install-host.sh's header, the README and the RUNBOOK's read-ahead
  section say sbx-read-ahead.service is enabled whatever
  SBX_WORKER_AT_BOOT says, so a host agent's later worker starts read
  ahead too; install-host.test.sh checks it (a worker installed with
  SBX_WORKER_AT_BOOT=0 still enables the read-ahead, not the worker).
- deploy/sbx/README.md: a blank line after the read-ahead paragraph,
  which ran into the next one.
- [email protected] (auto-merged): main's ExecStopPost and this
  branch's After=sbx-read-ahead.service both kept.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
@pdettori pdettori added this to the v0.11.0 milestone Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ai-review Request automated AI code review from clawgenti

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SBX0: a host boot starts every installed template worker, even under a host agent

4 participants