Skip to content

A released beta reaches a self-hosted install by itself, and a broken install is noticed - #879

Merged
nambok merged 2 commits into
mainfrom
fix/unattended-beta-updates
Nov 28, 2026
Merged

nambok merged 2 commits into
mainfrom
fix/unattended-beta-updates

Conversation

@nambok

@nambok nambok commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

A released beta now reaches a self-hosted install with no person in the loop, and a broken install gets noticed (incident vu). Four things stood in the way:

  1. Every release looked like a permission change. CloudFormation reports a Modify for every policy that names another part's output, because that value is known only after apply, even when the documents are byte for byte the same. The updater counted any IAM Modify, and a scheduled update that changes permissions waits for a person.
  2. The window was one hour a week or a day, so at most one of several daily betas could install.
  3. The watch after an update probed only the worker and the gateway. Chat runs in its own function with its own role, so a grant it lost left both of those healthy.
  4. The alarms couldn't fire. They counted Lambda Errors, which stay at 0 because the services catch and log every error.

The dashboard's settings control is CoderHelm/coderhelm#496.

Changes

Real permission changes (lambda/updater/handler.py: permission_changes, ChangeSides, template_resolve, resource_on, resource_difference)

  • Every change set (parent and parts) is read first. Then each IAM or resource-policy Modify is compared with the running release.
  • Both sides are resolved the way the template resolves them. The old side uses the running stack's template and parameter values. The new side uses the change set's template and parameters.
    • A Ref or GetAtt of the stack's own resource is the same resource on both sides, unless the change set replaces it.
    • An import that is known only after apply keeps its running value, as long as the parent feeds it the same way on both sides and the output it comes from resolves the same.
  • Policy documents are compared as IAM reads them (order ignored). Only a difference in actions, resources or conditions counts, and it is named, for example "PolicyDocument allows dynamodb:PutItem".
  • An Add always counts. So does anything that can't be compared (an unreadable template, a replaced resource, an export value). native_hold is unchanged, so a real widening still waits for a person.

Release notes (.github/scripts/iam_diff.py, release.yml)

  • The build job renders every role, policy and resource policy of the native templates for the previous release (the newest below the tag, a stable one for a stable tag) and for this one.
  • It compares them with the same functions the updater uses. Here no install values exist, so parameters stay symbolic and both branches of a condition are kept.
  • It writes the result to the step summary and to a release-notes artifact. The publish job appends that artifact to the GitHub release notes. dist/ and SHA256SUMS are untouched.

Beta any hour (validate_settings, in_window, gap_wait, last_install_at, decide)

  • New day: "any": on the beta channel, the hourly check installs each new beta, at least gap_hours (default 2, 1 to 168) after the last install that changed the stack.
  • On stable, "any" is refused, and moving to stable restores the default day. The stable channel keeps its window.
  • The gateway passes gap_hours through.

Chat probe (services/gateway/src/routes/stream_probe.rs, probe_chat and probe_release in the updater)

  • The streaming function answers POST /api/stream/probe, but only to a direct invoke whose request context names coderhelm-probe.invalid (404 otherwise). It makes Chat's own calls:
    • the member check every stream runs (require_sso::check_scoped), for a member that doesn't exist;
    • one call per action that infra/streaming-dynamodb.json grants the stream routes, on a key no record has. Writes carry a condition that can't hold, so nothing is written.
  • The updater invokes it with InvokeWithResponseStream during the watch.
    • A refusal fails the probe the same way a failed worker probe does, and rolls the release back.
    • A 404 (a release from before the probe) or AWS being busy is "unknown" and never counts.
  • The streaming function's Errors are read with the worker's and the gateway's.
  • The updater role gets ProbeChatAfterUpdate (lambda:InvokeFunction on the streaming function), and the fixtures are updated. This new statement is itself a real permission change, so the first update to this release asks once.

Alarms (infra/lib/monitoring-stack.ts)

  • Log metric filters count:
    • ERROR lines of the gateway, worker and streaming function (JSON $.level) and of the updater (Lambda's [ERROR] text line);
    • a new structured line event = "github_rate_limited", written once per refusal through RateLimited::logged;
    • a new event = "chat_answer" line with outcome answered or failed (sign-in check or model).
  • Each alarm is metric math on a share of traffic, not a count:
    • error lines per 100 invocations, at 10% or more;
    • rate-limit lines per 100 worker invocations, at 20% or more;
    • failed questions out of all questions asked, at 20% or more.
  • Each needs 3 of 4 15-minute periods, treats missing data as not breaching, and goes to the existing alerts topic.

Docs: docs/self-host/updates.md (Any hour, what counts as a permission change, Chat's health check) and docs/self-host/troubleshooting.md (the install's own alarms). Incident vu: services/worker/src/passes/incidents/vu_unattended_beta_and_alarms.rs and docs/incidents/vu_unattended_beta_and_alarms.md.

Verification

  • lambda/tests/test_updater_real_permissions.py, against a fake parent and two parts whose policy is reported as a dynamic Modify and whose import is known only after apply:
    • The same policy, and the same policy reordered, is no change. A scheduled update then executes and native_hold is "".
    • An added action is one change, and the scheduled update waits with "auto-update held: it changes permissions".
    • A new resource, a new condition, a changed feed, a changed output, a replaced source table and an unreadable template all count.
  • .github/scripts/test_iam_diff.py: reordering is no change; an added action, a changed branch, a changed condition and an added permission resource are listed; the previous-release choice for beta and stable tags is checked.
  • On real published releases:
    • Two recent betas: 99 permission resources resolve, none differs, and none is unknown.
    • The two betas around the Chat grant fix: exactly one difference is listed, the streaming role's dynamodb:GetItem resources.
  • lambda/tests/test_updater_beta_window.py:
    • "any" is beta only, and a stable move resets it;
    • every hour of a week installs;
    • the gap holds;
    • majors and auto-off still wait;
    • the tick starts a scheduled update at an hour no weekly window covers, and waits inside the gap;
    • every settings key passes through the gateway.
  • lambda/tests/test_updater_chat_probe.py:
    • the probe's event shape and parsing of the streamed answer;
    • a refusal, a 5xx and a function error fail;
    • throttling, a 404 and unanswered checks are unknown;
    • a Chat refusal during the watch rolls the release back to the earlier version, and a healthy Chat leaves it.
  • services/gateway/src/routes/stream_probe.rs tests: the probe makes one real call for every granted (action, table) and writes nothing; a member record that can't be read fails it; any request that isn't the updater's invoke gets 404 and runs none of its calls; every listed action is one the probe can make.
  • infra/test/log-alarms.test.ts (CDK assertions):
    • the four ERROR-line alarms, the rate-limit alarm and the Chat alarm are metric math over a log filter and traffic, into the alerts topic;
    • the filter patterns match the lines the Rust services write.
  • Local: cargo fmt --all --check, rustfmt --check --edition 2021 worker/src/passes/incidents/*.rs, cargo clippy -p common -p worker -p gateway --all-targets -- -D warnings, cargo test -p common -p worker -p gateway, python3 -m unittest discover -s lambda/tests (623), python3 -m unittest discover -s .github/scripts, infra npm test (198), check_workflows.py.
  • No live install's settings were changed.

… install is noticed

A beta never installed without a person, and a broken install went
unnoticed (incident vu):

- Permission changes are real ones. CloudFormation reports a Modify for
  every policy that names another part's output, since that value is known
  only after apply, even when the documents are byte for byte the same.
  permission_changes now compares each such Modify with the running
  release: both sides resolved the way the template resolves them (the
  running stack's parameter values, the change set's, an import keeping
  its running value when the parent feeds it the same way and its source
  output is the same), policy documents as IAM reads them. Only a
  difference in actions, resources or conditions counts; an Add, a real
  widening and anything that can't be compared still hold.
- The release notes list the permission changes against the previous
  release, with the same comparison (.github/scripts/iam_diff.py, a step
  in release.yml).
- The beta channel's window can be day "any": the hourly check installs
  each new beta, at least gap_hours (default 2) after the last install.
  Stable keeps its window; "any" is refused on stable.
- The watch after an update probes Chat: the streaming function answers
  a direct invoke of /api/stream/probe by making Chat's own calls (the
  member check every stream runs, one call per DynamoDB grant in
  infra/streaming-dynamodb.json, changing nothing). A refusal rolls the
  release back like a failed worker probe. The updater may invoke the
  streaming function (ProbeChatAfterUpdate).
- Alarms that can fire: log metric filters on ERROR lines (gateway,
  worker, streaming, updater), on a new structured GitHub rate-limit line,
  and on a new structured Chat answer line, each alarmed as a share of the
  traffic with metric math, into the alerts topic.
@nambok
nambok merged commit f816c7b into main Nov 28, 2026
12 checks passed
@nambok
nambok deleted the fix/unattended-beta-updates branch November 28, 2026 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant