Skip to content

Self-host updates never wait on the deploy role or its boundary - #519

Merged
nambok merged 2 commits into
mainfrom
self-host-updates-never-wait-for-permissions
Nov 8, 2026
Merged

nambok merged 2 commits into
mainfrom
self-host-updates-never-wait-for-permissions

Conversation

@nambok

@nambok nambok commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

A self-hosted update is never held back by a change to the deploy role or its permissions boundary again, and an install never stays stuck after such a change.

Root cause of v0.8.54-beta.20261108 "needs an AWS admin": the parent template's Boundary and DeployBoundary changed (PRs #511 and #516: Airflow, ECS and ECR reads, iam:Simulate*, the log analyzer's tag; the sts wildcard collapse rewrote two more statements). Every update runs as the deploy role, which the boundary forbids to change itself or a boundary, so the updater held the whole release for an AWS admin. That admin path could never work: the stack's service role is the deploy role, so CloudFormation runs a console Execute as that role too. On the live install it was denied (iam:DeletePolicyVersion on the boundary, iam:CreatePolicyVersion on the deploy boundary), the rollback was denied the same way, and the stack ended UPDATE_ROLLBACK_FAILED.

Changes

  • The parent never changes the access resources. Boundary, DeployBoundary and DeployRole come from infra/lib/native/access-pinned.json, byte for byte what v0.8.36 to v0.8.53 shipped. So the first release with this change installs on every install from v0.8.36 on through its current (older) updater, with no admin step, and brings the new updater with it.
  • Held updates. When a release's copies of those three differ from the install's, the updater keeps the install's own (keep_for, held_template). The helper's new stage_held writes that template to releases/<v>/held/coderhelm.json from the verified release (sha256 checked), only those three replaced, same type, no conditions. The updater checks the helper's canonical sha against its own and against what CloudFormation fetched. The updater role may create change sets from that path only.
  • Preflight. Before a change set made with the deploy role runs, each IAM call its changes need (parent and parts: managed policies, roles by changed property, inline policies) is evaluated against the deploy role's policies and boundary as IAM has them now (a small evaluator, the same rules as infra/test/iam-eval.ts). A call that would be refused, or a change to the role or a boundary, deletes the change set and ends the update as "couldn't start", naming the call and the rule. It is never offered for a console Execute. An update an older updater left waiting "for an AWS admin" ends the same way.
  • Access stack (the admin path, with the admin's own permissions). Each release publishes access.json, pinned by sha256 in ReleaseAssets and in the native tarball. It is a quick-create stack coderhelm-<name>-access with no service role. Its writer (lambda/native-access, inline, named CoderHelmAccess-<name> so no install role can invoke, pass or edit it) writes a new default version of each boundary and the deploy role's deploy policy, only where they differ. On delete it does nothing. The boundary already reserves the stack's name (TheAccessStackStays).
  • Status. native.access (cached 5 minutes) holds pending or applied, plain-words lines ("adds read access to Airflow, ECR and ECS (...)"), and the one quick-create link with the install's parameters. native.recovery reports a stuck rollback. pending.held and pending.preflight are new fields.
  • Stuck rollback recovery. On UPDATE_ROLLBACK_FAILED the updater reads which resources failed in the last rollback. For each one it compares the live IAM document (the managed policy's default version, the role's inline policies) with the rollback target's verified template. If all match, it runs ContinueUpdateRollback skipping exactly those. Otherwise it skips nothing, emails once and shows what differs. Tries are capped at 3. Proposing while the stack is stuck or busy is refused with a reason.
  • Degraded features. An AWS refusal that names a permissions boundary on an Airflow read says the install's permission change is pending and where to apply it (boundary_refusal, PENDING_PERMISSION_FIX).
  • CI flags boundary changes. infra/test/native-access.test.ts fails when today's boundary or deploy policy changes (ACCESS_DOCS) or the pinned file changes, with the reason. It also checks that every call in the simulator's deploy table is still allowed under the pinned boundary, so a held update can't fail on it, and that no install role reaches the access stack or its writer. cfn-lint now covers access.json.
  • Docs: updates.md (Permissions, A rollback that stopped, the state table), security.md.

Verification

  • python3 -m unittest discover -s lambda/tests: 397 tests OK. New test_updater_access.py:
    • the incident: stack RoleARN is the deploy role, the change set modifies Boundary and DeployBoundary, and the real pinned documents are used. The preflight reports iam:CreatePolicyVersion and iam:DeletePolicyVersion denied by TheBoundaryStays, the change set is deleted, and nothing executes or is offered;
    • a release with a boundary change installs the rest through the held template, built by the helper's real code;
    • a release without one is prepared exactly as before (public URL, stage only);
    • the access writer applies cleanly, drops the oldest version at IAM's 5, and writes nothing on a second run, after which the item reads applied;
    • recovery skips only what it verified unchanged, refuses when a policy differs, and the update ends rolled back.
  • infra: npm test 154 passed, 0 failed. cfn-lint 1.58.0 is clean on the built coderhelm.json, access.json and every part. The built parent's Boundary, DeployBoundary and DeployRole are equal to the published v0.8.53-beta.20261107's.
  • services: cargo fmt --check passes, cargo clippy -p common --all-targets -D warnings is clean, and cargo test -p common --lib live:: passed 237.
  • Not run: infra/scripts/deploy-role-sim.py --native needs AWS credentials and the owner's OK. No policy it simulates changed (deploy role, boundary and helper are unchanged), and its fixture tests pass.

… as installed, checked before running, newer permissions applied separately by an admin, stuck rollbacks finished
…rces, the preflight fails closed, recovery compares whole roles against verified templates only
@nambok
nambok merged commit 743b01d into main Nov 8, 2026
10 checks passed
@nambok
nambok deleted the self-host-updates-never-wait-for-permissions branch November 8, 2026 15:14
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