Repository navigation
feat(deploy/sbx): SBX0 idle lifetime - SBX_MAX_LIFETIME_DAYS and the workers' idle (#770) - #843
Conversation
…e maximum (rossoctl#770) Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…DS (rossoctl#770) Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…ngest lifetime (rossoctl#770) Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…ade (rossoctl#770) Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…LOWER_WORKSPACE_IDLE (rossoctl#770) A lowered SBX_MAX_LIFETIME_DAYS no longer lowers the bundles' SH_WORKSPACE_IDLE: sandboxes keep the deadlines set under the old maximum, so the run keeps the highest idle the bundles hold and says until when. SBX_LOWER_WORKSPACE_IDLE=1 writes the shorter idle, a host change acknowledged with SBX_ACK_HOSTS=1, whose text says the hosts take it at the next install-host.sh, which must come after the old maximum has passed. A raise is unchanged. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…ssoctl#770) off writes no SH_SANDBOX_MAX_LIFETIME_SECONDS, so the control plane keeps the absolute lifetime, and derives the workers' idle from SBX_LIFETIME_DAYS plus two days, as before (216h at 7 days): an existing deployment takes this setup.sh, and routine runs, with no host change until the day the hosts are reinstalled. Validation takes 1-30 or off; the default-within-maximum check applies only to a number. The key's position in sbx-settings, and so the settings hash, is unchanged. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…dles are unknown (rossoctl#770) With no worker bundle in .generated/workers for the configured workers, check_host_idle has nothing to compare, so on an existing deployment a run could turn sliding on while the hosts still run 216h. When the live sbx-settings exists and its SH_SANDBOX_MAX_LIFETIME_SECONDS is absent or differs from this run's, the run now refuses before anything is applied unless SBX_ACK_HOSTS=1 (then it names every worker to reinstall). off, a fresh namespace and the maximum sbx-settings already holds pass. The test mock reads ConfigMaps back. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…ossoctl#770) A worker env with no SH_WORKSPACE_IDLE line prints "missing (no SH_WORKSPACE_IDLE in <file>)" instead of "not whole hours". The test's ssh mock takes --token-ttl-seconds as optional too, and a new case proves the cluster side runs the host side with the maximum alone when the token lifetime is unknown. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
The RUNBOOK's 216 h to 768 h is at the defaults; install-host.sh's comment and example follow the maximum idle lifetime (idle-lifetime spec §6.2); the overlays' comment says what an absent maximum means; README and RUNBOOK drop "reinstall first", since a refused run writes no bundles. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Summary
This is plan 3 of #770. SBX_MAX_LIFETIME_DAYS (1-30 or off, default 30) goes into sbx-settings as SH_SANDBOX_MAX_LIFETIME_SECONDS, which both sbx overlays read optionally. Each worker's SH_WORKSPACE_IDLE now follows the maximum: max×24+48 h, so 768 h by default. That closes the gap between the worker idle and live sandbox deadlines that #837's review raised. I checked each case against the code, the tests and the README/RUNBOOK:
- a raise goes through
SBX_ACK_HOSTS - a lowering keeps the highest bundled idle until
SBX_LOWER_WORKSPACE_IDLE=1 offkeepslifetime+48h- a lost
.generatedis refused status.sh --hostwarns when an idle is at or below the maximum
The shell stays bash-3.2 clean. I have one suggestion about the remaining lost-.generated path, and three nits.
Merge order: docs/sbx/user-guide.md §7 still says "A sandbox's lifetime cannot be extended". #842 rewrites it, so please land #842 before (or with) this PR, or the guide is wrong for #837+#843 deployments.
Author: pdettori (MEMBER, maintainer)
Areas reviewed: Shell, Kubernetes overlays, Docs, Tests
Agent/IDE config (.claude/.vscode): none
Commits: 9 commits, all signed-off: yes
CI status: passing (17/17)
| # idle lifetimes on or changes the maximum is refused, before anything is applied, unless | ||
| # SBX_ACK_HOSTS=1; a fresh namespace, off, and the maximum sbx-settings already holds pass. | ||
| check_unknown_bundles() { | ||
| [[ -n "$MAX_LIFETIME_S" ]] || return 0 |
There was a problem hiding this comment.
suggestion: check_unknown_bundles returns early for off, and it never treats a live maximum higher than this run's as a lowering. That leaves one path where this PR still writes an idle shorter than the live deadlines, with no refusal:
- An earlier run sets
SBX_MAX_LIFETIME_DAYS=30. Hosts are at 768 h, and sandboxes hold deadlines of up to 30 days. .generated/workersis lost.- A run with
off, or with a lower number plusSBX_ACK_HOSTS=1, writes 216 h (or max+48 h) bundles. In the lowered case it also says to re-run install-host.sh now. - The next routine
install-host.shmakes those workers reclaim live workspaces.
The body lists both cases as follow-ups, but you could close them here. Read live before the off return. When it is non-empty and greater than ${MAX_LIFETIME_S:-0}, floor WORKSPACE_IDLE_H to live/3600 + 48, with SBX_LOWER_WORKSPACE_IDLE=1 bypassing the floor as it does in check_host_idle. The "off … pass" in the comment above (:515-517) is where the gap is.
There was a problem hiding this comment.
Fixed in 4a1b4f4, as you proposed. read_live_max reads the live SH_SANDBOX_MAX_LIFETIME_SECONDS in preflight, before the off return. When that value is higher than this run's (a lowering, or off), the idle is floored at ceil(live/3600)+48 unless SBX_LOWER_WORKSPACE_IDLE=1, through the same kept path as the bundle floor. The higher of the two floors wins. The end text no longer says "now" after a kept or opt-in lowering. To get that ordering, check_host_idle and check_host_ceiling moved from validate to preflight. They still run before anything is applied or written, and the tests still assert an empty mock log after each refusal. New tests cover a lost .generated with a live 30 d maximum under off, under 20 d with the ack, and under each of those with the opt-in.
| local cause="SBX_MAX_LIFETIME_DAYS changed, or this deployment's idle now follows it" | ||
| [[ " $olds " != *" unset "* ]] || cause='a bundle from before increment 1b carries none' | ||
| if [[ "${SBX_ACK_HOSTS:-}" != 1 ]]; then | ||
| die "SH_WORKSPACE_IDLE changes from${olds} to ${WORKSPACE_IDLE_H}h for worker(s) ${HOSTS_TO_REINSTALL} (${cause}), and a running worker keeps its old value until deploy/sbx/install-host.sh is re-run on its host. Re-run install-host.sh on every host first, or set SBX_ACK_HOSTS=1 to apply now and re-run install-host.sh with the new bundles on every host right after" |
There was a problem hiding this comment.
nit: This refusal still offers "Re-run install-host.sh on every host first". The README (~:131) and RUNBOOK §3 dropped that option in this PR, because only an acked run writes the bundles that carry the new idle, so there is nothing to reinstall first. I suggest dropping the clause so the message matches the docs.
There was a problem hiding this comment.
Fixed in 8d3f163. The raise refusal now offers only the ack-then-reinstall route, matching the README and RUNBOOK.
| ``` | ||
|
|
||
| writes the shorter idle into the bundles; the hosts take it when `install-host.sh` is next run on | ||
| them. Never set `SBX_LOWER_WORKSPACE_IDLE=1` before the old maximum has passed: a routine reinstall |
There was a problem hiding this comment.
nit: This warns against setting SBX_LOWER_WORKSPACE_IDLE=1 too early, but not against keeping it set. If an operator puts it in the env file (sourced with set -a), a later lowering skips the "kept" step. With SBX_ACK_HOSTS=1 also in the file, the shorter idle is written at once. Worth adding: "pass it on the command line for that one run; do not keep it in the env file". The same applies to the setup.sh header (:35-37).
There was a problem hiding this comment.
Fixed in 8d3f163. The setup.sh header, the README and RUNBOOK §3 now say to pass SBX_LOWER_WORKSPACE_IDLE=1 on the command line for that one run and never keep it in the env file, with the reason you gave.
| # The old maximum, in days, rounded up: the idle is that plus two days. | ||
| local old_days=$(((high - 48 + 23) / 24)) | ||
| if [[ "${SBX_LOWER_WORKSPACE_IDLE:-}" != 1 ]]; then | ||
| log "SH_WORKSPACE_IDLE would drop from ${high}h to ${WORKSPACE_IDLE_H}h with the lower maximum: kept at ${high}h until SBX_LOWER_WORKSPACE_IDLE=1 is set, which is safe only once the old maximum (${old_days} days) has passed since the run that lowered SBX_MAX_LIFETIME_DAYS (sandboxes keep the deadlines set under it)" |
There was a problem hiding this comment.
nit: This log is also printed when switching to off over 768 h bundles. Nothing was lowered in that case, and SBX_MAX_LIFETIME_DAYS is not a number, so "with the lower maximum … since the run that lowered SBX_MAX_LIFETIME_DAYS" reads wrong. Consider separate wording for off, and a test that off over 768 h bundles keeps 768 h (there is none today).
There was a problem hiding this comment.
Fixed in 8d3f163. off now has its own kept wording: idle lifetimes are off, but sandboxes may still hold deadlines from the previous maximum. The missing test is added. off over 768h bundles keeps 768h, a second off run keeps it from the bundles alone, and 216h is written only with SBX_LOWER_WORKSPACE_IDLE=1 plus the ack.
- The raise refusal no longer offers "re-run install-host.sh on every
host first": a refused run writes no bundles, so there is nothing to
reinstall first. It offers SBX_ACK_HOSTS=1 and a reinstall right after.
- SBX_MAX_LIFETIME_DAYS=off over longer bundles keeps their idle in its
own words ("idle lifetimes are off now ..."), not as a lowered
maximum, and the wait for SBX_LOWER_WORKSPACE_IDLE=1 counts from the
run that turned idle lifetimes off. Tested: off over 768h bundles
keeps 768h; only the opt-in plus an ack writes 216h.
- SBX_LOWER_WORKSPACE_IDLE goes on the command line for one run, never
in the env file (setup.sh header, README, RUNBOOK).
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
…ow the live maximum (rossoctl#770) check_unknown_bundles returned early for off, and never read a live maximum higher than this run's as a lowering. So with .generated/workers lost after a 30 d run, an off run (or a lower number with SBX_ACK_HOSTS=1) wrote 216h (or max+48h) bundles, and the next routine install-host.sh would reclaim workspaces of sandboxes still holding 30 d deadlines. preflight now reads sbx-settings' SH_SANDBOX_MAX_LIFETIME_SECONDS once (read_live_max) and then runs check_host_idle and check_host_ceiling (moved from validate), so check_host_idle floors SH_WORKSPACE_IDLE at the higher of the bundles' idle and the live maximum plus two days, with the same "kept" log, until SBX_LOWER_WORKSPACE_IDLE=1. With no bundles, a kept lowering names no host to reinstall; off passes; a lowered number still needs SBX_ACK_HOSTS=1 as any changed maximum there; SBX_LOWER_WORKSPACE_IDLE=1 under a higher live maximum is a host change, refused unless acknowledged (off included). All before any apply; bundles are written last. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
|
Review follow-ups are pushed (8d3f163, 4a1b4f4). All nine |
Takes upstream main at 1a7f41e (19 merges since 032c8f6): the sandbox idle lifetime across docs, control plane, clients and deploy (rossoctl#820, rossoctl#837, rossoctl#842, rossoctl#843), grant redemption (rossoctl#822), the lease-check log line (rossoctl#824), egress fixes (rossoctl#829, rossoctl#834), the mock wait (rossoctl#828), the deadline timer (rossoctl#835), the create rollback (rossoctl#832), multi refusals and the rossoctl#363 leftovers (rossoctl#833, rossoctl#838), the identity near-miss check (rossoctl#827), mocactl login errors (rossoctl#836), the ghostunnel probes (rossoctl#830), refusal-burst deferral (rossoctl#831), a sandbox-worker change (rossoctl#841) and the v0.11 doc truth (rossoctl#821). Conflicts (one): - deploy/sbx/README.md, the "Optional inputs" table. Upstream (rossoctl#843) rewrote the SBX_LIFETIME_DAYS row (the default idle lifetime, at most SBX_MAX_LIFETIME_DAYS) and added the SBX_MAX_LIFETIME_DAYS and SBX_LOWER_WORKSPACE_IDLE rows, which widened the table; the fork had added an SBX_GATE_RECORD_SCHEMA row at its end. Resolved by taking upstream's table whole and appending the fork's SBX_GATE_RECORD_SCHEMA row after SBX_PROFILE, then re-padding the table with prettier. The fork's env-file example line for SBX_GATE_RECORD_SCHEMA merged cleanly. Merged without markers, checked: setup.sh keeps the fork's SBX_GATE_RECORD_SCHEMA validation and its sbx-settings write (so it stays in the settings hash) beside upstream's SH_SANDBOX_MAX_LIFETIME_SECONDS; both ocp-sbx and ocp-combined patch-control-plane.yaml keep the optional SH_GATE_RECORD_SCHEMA from sbx-settings beside the new optional SH_SANDBOX_MAX_LIFETIME_SECONDS; setup.test.sh keeps the fork's cases beside upstream's. The fork's RUNBOOK, README and template-onboarding docs say nothing about sandbox lifetime, refusal bursts, login errors or the create rollback, so none needed a correction; GUIDE.md is unchanged and GUIDE.pdf is not regenerated. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
… caveat (#770) The idle-lifetime spec moves to v0.2, implemented in #837, #842 and #843 and shipping in v0.11.0, and records what the build decided (sliding only once the maximum is configured, doctor and sbx env, SBX_MAX_LIFETIME_DAYS=off, a lowered maximum keeping the workers' idle). The registry row reads implemented. The deploy README says to keep deploy/sbx/.generated/workers until a lowered maximum's old value has passed: the kept idle lives only in those bundles. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Summary
Plan 3 of 3 for #770 (spec:
docs/specs/2026-11-16-sbx-idle-lifetime-design.md§6). This makesdeploy/sbxturn idle lifetimes on safely. It's independent of #837 and #842: an older control plane ignores the new key.SBX_MAX_LIFETIME_DAYSsets the longest idle lifetime an owner may pick withmocactl sbx create|up --lifetime.off, default 30, and at leastSBX_LIFETIME_DAYS.sbx-settingsasSH_SANDBOX_MAX_LIFETIME_SECONDS. With feat(control-plane): SBX0 idle lifetime - activity mints slide the deadline (#770) #837, that key is what turns idle lifetimes on in the control plane.SH_WORKSPACE_IDLEis nowmax × 24 + 48h (768 h at the default) instead ofSBX_LIFETIME_DAYS + 2 d. The existing "idle changes, so refuse unlessSBX_ACK_HOSTS=1" guard now fires on the maximum. Changing onlySBX_LIFETIME_DAYStouches no host.SBX_MAX_LIFETIME_DAYS=offis the way to take thissetup.shbefore the hosts can be reinstalled. No key is written, so the absolute lifetime stays. The idle stays as before (216 h), and routine runs (enrolling a user, quotas) need no host change.SBX_LOWER_WORKSPACE_IDLE=1is set, which is safe only once the old maximum has passed. That opt-in then goes through the refusal and ack with lowering-specific text.deploy/sbx/.generated/workerson an existing deployment no longer turns idle lifetimes on silently. The run refuses unless acked.ocp-sbx,ocp-combined) read the key withoptional: true.status.sh --hostprintsworker idle <id>: …against the maximum, which the cluster side passes as--max-lifetime-seconds, falling back toSH_SANDBOX_LIFETIME_SECONDS. It warns for an installed worker that would reclaim a live sandbox.off, lowering, and the status line.Upgrade order for an existing SBX0
If the hosts can't be reinstalled that day, use
SBX_MAX_LIFETIME_DAYS=offuntil they can.Test evidence
deploy/sbx/tests/*.test.shpass under macOS/bin/bash3.2.57, thedeploy-scripts-bash32target. The tests cover the upgrade from 216 h bundles, a default-only change, raising and lowering the maximum (with and without the opt-in),off, a lost.generated, the overlay keys, and the status host and cluster sides.shellcheck -x -S warning(0.11.0, CI's flags) is clean on everydeploy/sbxscript. Prettier is clean.Known follow-ups (minor, not on the normal upgrade path)
.generated, a lowered maximum and an ack together write the shorter idle and say "reinstall now". The fix is to floor the idle from the live ConfigMap's higher maximum.offover 768 h bundles. On reading, the idle is kept at 768 h without the opt-in.offcombined with a lost.generatedwrites 216 h bundles without a refusal.Part of #770. Merge before any SBX0 deployment runs with idle lifetimes on.
Assisted-By: Claude Code