Repository navigation
docs(sbx): a recipe for reproducing a member's issue (#857 R4) - #880
Conversation
Adds "Reproducing a member's issue" to deploy/sbx/RUNBOOK.md: the member's `--record` file, the sandbox's egress log (`sbx egress --ndjson`, then `--verify`), and the control-plane, relay, Redis `sh:cp:audit` and KVM-host journal lines for one sandbox id or subject in a time window, with commands and jq filters checked against the line formats in the code. It says what is not stored (no command text or output, unless the relay's debug flag) and the retention as it is today, points to the R2 sampler for host load (status.sh --host until then), and notes the queries move to the R1 pipeline once one is chosen. The user guide links to it. Part of rossoctl#857 Assisted-By: Claude Code Signed-off-by: Rong Chang <[email protected]>
pdettori
left a comment
There was a problem hiding this comment.
Summary
Docs-only: a recipe for assembling one bundle per sandbox when a member reports a problem, linked from the user guide. I checked every command, flag and field name against the code on this head: the NO_RECORD set and the exit-2 refusals, --ndjson/--verify exclusivity and their output strings, epoch-seconds createdAt, the timestamp-less stdout audit line, XADD * ids on sh:cp:audit (so XRANGE by ms works), the relay's ISO ts (so the string <= $to compare is valid), Deployment/container/redis-0 names (redis-cli authenticates from the container's REDISCLI_AUTH), workspace_key=%q, egress sid/via, the egress caps and 600 s grace, the trim lengths, and the §2/§7/§8 cross-references. I also ran the control-plane jq filter, ms() and the Redis awk filter on sample lines. One small accuracy issue in the awk filter's $SUB use, inline.
Author: webchang (MEMBER — maintainer)
Areas reviewed: Docs (shell/jq/awk snippets in Markdown)
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, all signed-off: yes
CI status: passing
Assisted-By: Claude Code
| { r = r " " $0 } END { if (r ~ k) print r }' | ||
| ``` | ||
|
|
||
| Each line printed is one entry: its id, then its fields and values. Use `-v k="$SUB"` for the |
There was a problem hiding this comment.
suggestion: -v k="$SUB" over-matches: r ~ k is a substring regex match and subjects are github:<numeric id>, so github:1 also prints github:12's and github:100's entries (reproduced on sample XRANGE output: two entries instead of one). $SBX is safe because ids are a fixed sbx- + 26 hex. Matching the whole value avoids it:
awk -v k=" $SBX " '/^[0-9]+-[0-9]+$/ { if (index(r " ", k)) print r; r = $0; next }
{ r = r " " $0 } END { if (index(r " ", k)) print r }'and -v k=" $SUB " here (tested on both cases).
There was a problem hiding this comment.
Fixed in a3223b9 with your filter (whole value, spaces on both sides), and the text now says why github:1 no longer matches github:12.
| ms() { jq -nr --arg t "$1" '$t | strptime("%Y-%m-%d %H:%M:%S") | mktime * 1000'; } | ||
| kubectl -n "$NS" exec redis-0 -c redis -- \ | ||
| redis-cli XRANGE sh:cp:audit "$(ms "$FROM")" "$(ms "$TO")" | | ||
| awk -v k="$SBX" '/^[0-9]+-[0-9]+$/ { if (r ~ k) print r; r = $0; next } |
There was a problem hiding this comment.
nit: "Checked against the code:" precedes each of the five blocks, on top of the section intro saying the same. Once the recipe has had a live run, consider collapsing it to the one intro sentence so it doesn't go stale five times over.
There was a problem hiding this comment.
Agreed: once the recipe has had its first live run, I will collapse the five "Checked against the code" lines into the intro sentence, as part of that run's update.
Review follow-up: `r ~ k` is a substring regex match, so `github:1` also matched `github:12`'s entries. The filter now matches the whole value with spaces on both sides (`index(r " ", " $SUB ")`), as the reviewer suggested and tested. Part of rossoctl#857 Assisted-By: Claude Code Signed-off-by: Rong Chang <[email protected]>
Brings rossoctl#878 (the sync /runs disconnect contract), rossoctl#880 (the RUNBOOK's reproduction recipe) and rossoctl#882 (deploy/k8s SH_WORKSPACE_IDLE for the container worker, default 8h). No conflicts. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
Part of #857 (R4): a runbook recipe for reproducing a member's issue
What changed and why
deploy/sbx/RUNBOOK.mdgains Reproducing a member's issue, so an operator who did not writethe tooling can assemble one bundle for one sandbox. It covers:
mocactl sbx ls --all --json, andthe fact that the host logs the sandbox under its workspace key, which is the sandbox id;
--recordfile: where the flag goes (aftersbx <command>orrun), whichcommands refuse it, what a line holds, what is hashed or reduced to a length, the 0600 file,
and that Exec calls (gRPC) are not in it;
mocactl sbx egress <id> --ndjson, then--verifyas a separate run (theCLI refuses both flags together), and what
--verifyprints;"event":"audit"lines (--timestamps, since these lines carry no time),the relay's
"audit":"sandbox_*"lines, the Redis streamsh:cp:audit, and the KVM host'ssbx-worker@<wrk>,sbx-janitorandmoca-egressjournals, each with the exact command anda jq or awk filter on
sandboxId/subject,sbx/sub,wskorsid;status.sh --hostis a one-shot view of now(unit states, the workspace
df, the janitor), with no CPU, memory or pressure figures;cmdonly with thedebug flag
SH_SANDBOX_AUDIT_COMMANDS=1, as in the security review), and today's retentionfor pod stdout,
sh:cp:audit(trimmed to about 1,000,000 entries), egress logs and journald;docs/sbx/user-guide.mdlinks the section from its operator pointer and from the--recordparagraph, so a member knows why an operator may ask for a record.
How it was checked
the source it cites:
packages/mocactl/src/sbx/cli.tsandcall-record.ts(--record),packages/mocactl/src/sbx/commands.ts(cmdEgress,verifyEgress),packages/control-plane/src/handler-util.ts,ownership.ts,sandbox-handlers.ts,egress-log.ts,routes.ts,packages/sandbox-relay/src/sandbox-caller.ts,remote-worker/internal/vmpool,remote-worker/internal/egress/audit.go,deploy/sbx/janitor.sh,host-agent.sh,status.sh,setup.sh, and the Deployment andcontainer names in
deploy/k8s/baseanddeploy/k8s/overlays/ocp-sbx.(including non-JSON lines mixed in, which the filters skip).
npx prettier --checkon both files andpython3 scripts/check-doc-links.py(0 broken links).Out of scope
today's behavior only.
Every commit is signed off (DCO).
Assisted-By: Claude Code