Repository navigation
Conversation
…, re-posts, one writer per environment) - --apply (a run or any action) refuses to start without ROLLOUT_DISCORD_WEBHOOK, before it reads anything. - A run fails when none of the environment's installed hosts in the plan has its deploy branch on the remote. The plan now says whether each host is installed: lib.mkFleet's host.json, and true for any other host. - A cluster API that doesn't answer counts as the host in flight not being back yet, on its last state's budget, then halts and posts; with nothing in flight the run fails without moving anything. - Halts and long waits post again every budgets.repost minutes (240). - write_state stops without pushing when the environment's own state file changed since the run read it; another environment's change is still rebuilt on top. - Fingerprints are evaluated --eval-batch hosts per nix eval (10). - ROLLOUT_RUN_URL sets the notices' run link. - approveEvery: listed later environments take only an approved commit.
…me, abandon and approve; updater tasks get credentials Updater tasks get credentials.<NAME>: a secret file on the host, loaded with LoadCredential and found at <NAME>_FILE (%d/<NAME>), refused at evaluation in the store or as a Nix path, and out of every task's reach but through its own credentials directory. The promoter reads its webhook from ROLLOUT_DISCORD_WEBHOOK_FILE, refresh-keys from WEBHOOK_FILE. Under UPDATER_TASK the promoter fetches nothing, reads GitHub with the pusher's read token in gh's environment alone, moves deploy branches with updater-push and the toplevel it built at the target, and writes rollout-state with updater-push from the parent it built on, stopping when that's refused. In GitHub Actions its git and gh calls are as before, held to a recording of the previous promote.py. host-promote requests acts once on each run of a read-only request workflow dispatched on the default branch by an actor (and triggering actor) in the requesters file, with a run-name of exactly <env> resume|abandon or <env> approve <full commit>, recording the run id in the same state write as the action; anything else it refuses with one notice.
lib.mkFleet's fleet install pushes a host's deploy branch before it installs it, so a host host.json calls installed that has no branch lost it, or the token can't read it, and converging without it would stage a commit it never ran. The plan's installed is now true or false from host.json and null for any other host, which may not be migrated yet: those still fail the run only when none of them has its branch.
There was a problem hiding this comment.
Summary
The PR runs the promoter as an updater task (pusher-backed writes, gh read token, no fetch), adds a host-promote requests reader for resume/abandon/approve, per-task credentials loaded with systemd's LoadCredential, approveEvery, and halt/wait reposts. The implementation is careful and well tested, but the two previously open findings still hold: per-task credentials are pooled at the repository's user, and approve/abandon still require a reachable cluster.
Issues
- 🟡
modules/updater/default.nix:680— A credential is readable by every task of the same repository, not just its own — see the thread on that line - 🔴
rollout/promoter/promote.py:622— approve and abandon fail on an unreachable cluster though they never read it — see the thread on that line
Reviewed @ 48dd1ae2
"The best code is no code at all." — Jeff Atwood
| # The task's own secrets, read by systemd before it sandboxes the | ||
| # unit. toString: a Nix path (refused above) must not reach the | ||
| # store here. | ||
| LoadCredential = lib.mkIf (t.credentials != { }) ( |
There was a problem hiding this comment.
🟡 A credential is readable by every task of the same repository, not just its own
systemd grants the unit's user an ACL on /run/credentials/<unit> and owns the credential files by that user, and every task of a repository runs as the same updater-<repository> (line 668) — so while updater-fleet-a-promote.service runs, a concurrently running updater-fleet-a-bump.service can read its KUBECONFIG/webhook from /run/credentials/updater-fleet-a-promote.service/. InaccessiblePaths (line 686) only hides the source files, and the new VM subtest (tests/vm/updater.nix:393) checks only another repository's task. Since tasks run the repository's code at the default branch tip, this undercuts the per-task secret isolation the option describes; either state that a repository is the credential trust domain, or give tasks separate users / bind only their own credentials directory.
| try: | ||
| self.cluster = load_cluster(args.context) | ||
| except Unreachable as err: | ||
| if args.action != "run": |
There was a problem hiding this comment.
🟡 approve and abandon fail on an unreachable cluster though they never read it
__init__ re-raises Unreachable for every action but run, yet only resume uses self.cluster (in manual(), via logic.baseline); approve and abandon touch neither the cluster nor the nodes, so a cluster outage needlessly blocks them — and the halt notice for an unreachable API tells people to resume/abandon. With the new reader this is worse: Reader.handle only catches SystemExit, so an approve/abandon request raises out and aborts the whole pass (later queued requests included) instead of refusing that one. Only re-raise for resume, or load the cluster lazily.
…ollout-state The second push's old is where the first left the ref, with no fetch between them, and it passes; a stale old is still refused as moved.
Stacked on #76 (the daily jobs as updater tasks), with #77 (the promoter fails closed) merged in; review only the last commit here.
The promoter now also runs as a task of
nixosModules.updater, and a newhost-promote requeststakes the place of GitHub's "Run workflow" button for resume, abandon and approve. WithoutUPDATER_TASK, in GitHub Actions, the promoter issues the same git pushes and fetches and gh reads as before; a new test holds it to a recording taken from the promoter before this change.Credentials for updater tasks. A task's
environmentis in the Nix store, so there was no safe way to give one a secret. The new per-taskcredentials.<NAME> = "/run/secrets/…":LoadCredentialinto that unit's credentials directory;<NAME>_FILE(%d/<NAME>, which systemd expands inEnvironment=), never as a value in the environment or argv;keyFilehad, now shared), or when its name isn't a variable's.Every task's credential files, like the keys, are in every task's
InaccessiblePaths: a task reads its own only through its credentials directory. A program that takes a path in a variable of its own gets it with%dinenvironment, such asKUBECONFIG = "%d/KUBECONFIG".ROLLOUT_DISCORD_WEBHOOK_FILEwhenROLLOUT_DISCORD_WEBHOOKisn't set.--applycounts either.WEBHOOK_FILEthe same way (ci/lib.sh'sfrom_file). The value stays unexported.The promoter under the updater:
check_passed, and the reader's listing) reads withupdater-read-token's token, given only to gh's environment and asked for again with under 10 minutes left.GH_REPOnames the repository.updater-push --old <as read> --new <target> --toplevel <path>. The path comes fromnix buildof that host'ssystem.build.toplevelat the target. A refused or failed push (or build) fails the run after the move is recorded, as a failedgit pushdoes in Actions.rollout-statemoves throughupdater-pushwith--oldthe commit the write was built on.origin/<branch>moves asgit pushwould, so the next environment in the same task reads it.apply = false) counts as success. It moves nothing locally, says so in the log, and posts no notice: each run would post the same ones again.staging resume,production approve <full id>) instead of the promote workflow.The request reader.
host-promote requests --requesters FILE [--workflow request.yaml] [--max-age-hours 24] [--context [ENV=]CONTEXT] [--apply]:event=workflow_dispatch, the default branch), oldest first.actorandtriggering_actorare both in the requesters file, which comes from the updater host's configuration, not the fleet repository;<environment> resume|abandonor<environment> approve <40-hex commit>.--actionpath and names who asked in the notice. The run id goes into that environment's state in the same write as the action (requests, the last 200, kept across new rolls), so a second pass or a fresh checkout doesn't act again._requests.jsonon the state branch, and it's posted only once. A refusal that fails to post isn't recorded, so the next pass tries again.--applyit only says what it would do.The README has an example task and request workflow. The workflow's job never runs, so it needs no runner. It's written as
if: github.event_name != 'workflow_dispatch'because actionlint refuses a constantif: false.Tested:
rollout/promoter/test_promote.py: 18 new tests, with stubs forupdater-push(compare-and-swap, no creating, a toplevel for deploy branches, pushed or dry-run),updater-read-token,gh,nix buildand a logginggit. Every existing test passes unchanged.updater-pushcalls for a deploy move and a state write;triggering_actor, with one notice;ROLLOUT_DISCORD_WEBHOOK_FILE.fixtures/actions-calls.txt, recorded from the previouspromote.py.updater/test_pusher.py: a ref pushed twice in one run, as the promoter writesrollout-state. The second push's--oldis where the first left the ref, with no fetch between them, and it passes; a stale--oldis still refused.updater-config: a credential in the store, as a Nix path, or with a bad name is refused. A valid one reaches its unit'sLoadCredentialand<NAME>_FILE, and the unit file has%dunescaped. Another repository's task gets none, and no task reaches the file.tests/fleet/test-jobs.sh: refresh-keys readsWEBHOOK_FILE, keeps it out of commands' arguments and environment, and fails before anything when the file can't be read. The GitHub Actions recordings are unchanged.tests/vm/updater.nix: a task reads its own credential from$SECRET_FILE, in$CREDENTIALS_DIRECTORY. Neither its own credential's file nor another repository's is readable, even at mode 0644, and neither is another repository's credentials directory while that task runs. Run here under TCG; CI runs it with KVM.formatting,rollout-plan,promoter,updater-pusher,updater-config,fleet-scripts,fleet-example,fleet-rules,workflowsandcipass.Worth reviewing:
apply = false, notices are printed, not posted.--context [ENV=]CONTEXTon the reader, for fleets with one kubeconfig context per environment._requests.jsonas the reader's own record on the state branch. Environment names can't start with_.display_title(the run-name) and ofpathwith or without@<branch>.Not verified:
createdfilter,display_title, andpath's exact form for a dispatched run.