docs: runbook PPv2 section follows the current step tool
Continuous observation across apply and the probes, reverify after any interruption, a completable S3 incident path, deployment order and window gates, and a shorter section.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+65
−68
docs/region-ha-runbook.md+65 −68
Intent
diff --git a/docs/region-ha-runbook.md b/docs/region-ha-runbook.md| index 5cbfe913d..35c214861 100644 |
| --- a/docs/region-ha-runbook.md |
| +++ b/docs/region-ha-runbook.md |
| @@ -348,28 +348,26 @@ For new fixed boxes, have the deployment's host-init copy the reviewed `scripts/ |
| A region NLB can pass the client address to its targets in a PROXY protocol v2 header instead of by client IP preservation. The design is in `docs/superpowers/specs/2026-11-12-edge-proxy-protocol-design.md`. This section is for the operator who runs the cutover and for anyone who rolls a release onto NLB targets afterwards. |
| -Each target group is in one of four states: |
| +A target group is in one of four states: S0 (preservation on, PPv2 off, today), S1 (preservation on, PPv2 on; targets ignore the header), S2 (preservation off, PPv2 on; the goal), and S3 (preservation off, PPv2 off; forbidden, because a client's own header would be believed). The step tool moves S0 to S1, S1 to S2 and S2 to S1. Nothing turns PPv2 off. |
| -- **S0:** preservation on, PPv2 off. Today. |
| -- **S1:** preservation on, PPv2 on. Targets still see the client address and ignore the header. |
| -- **S2:** preservation off, PPv2 on. The target. Targets trust the header from the NLB node addresses. |
| -- **S3:** preservation off, PPv2 off. Forbidden. A client's own header would be believed. |
| +### Order and gates |
| -The only moves are S0 to S1, S1 to S2 and S2 to S1. Nothing turns PPv2 off. |
| +- Dev IE first, in a dev #421 window, after vN is on dev. |
| +- Flagship US only after every dev witness row passes, in a flagship window with the lock posted on #421, and before G6 opens the US NLB to customers. |
| +- Never in the same window as a release roll or a group roll. The one exception is the group roll the prerequisites ask for. |
| +- The first apply of each kind needs the agent manager's GO. |
| ### Prerequisites, per NLB |
| -Do these in order. A target is a fixed box or a group member. |
| +In this order: |
| -1. Every target in both target groups runs build vN or later. Roll the fixed boxes. Replace members through the group roll onto a launch template that names vN. |
| -2. The region's `boot/bootstrap-object` and `boot/bootstrap-sha256` name a vN build. Check them in SSM and check the object's hash. Do this before you publish the key: a bootstrap below vN refuses the key and stops every new member at boot. |
| -3. Publish `CARLOS_INGRESS_PROXY_SOURCES`, equal to the module's output. Put it in the region's host-env parameters and run a group roll, because members write host.env only at launch. Put it in each fixed box's host.env and restart with a drain. The journal of every target must show the armed line (`edge: proxy protocol: armed on :80 and :443, trusting ...`) with exactly the module's addresses. |
| -4. Apply the group module at vN, so its precondition accepts the new states. |
| -5. Set `CARLOS_HOST_METRICS=cloudwatch` on every target. Set the module's `proxy_trust_alarm` input and apply. Both alarms must be in OK, and you must have seen a notification arrive. |
| +1. Every target in both target groups runs vN or later. Roll fixed boxes. Replace members through the group roll onto a launch template naming vN. |
| +2. The region's `boot/bootstrap-object` and `boot/bootstrap-sha256` name a vN build (check SSM and the object's hash) before you publish the key. A bootstrap below vN refuses the key and stops every new member at boot. |
| +3. `CARLOS_INGRESS_PROXY_SOURCES` equals the module's output, in the region's host-env parameters (then a group roll, because members write host.env only at launch) and in each fixed box's host.env (drained restart). Every target's journal shows `edge: proxy protocol: armed on :80 and :443, trusting ...` with exactly the module's addresses. |
| +4. The group module is at vN. |
| +5. `CARLOS_HOST_METRICS=cloudwatch` on every target, the module's `proxy_trust_alarm` set, both alarms applied and in OK, and a notification seen arriving. |
| -Arming changes nothing on the wire. Until A80 no connection carries a header. |
| - |
| -Check the list with the step tool. It writes `prereq.json` into the record directory: |
| +`prereq` checks only the automated part: both target groups in S0, every target armed with the NLB's node addresses, the barrier down, the trust alarm OK. It writes `prereq.json`, including the NLB's public addresses, which the probes must target. Items 1, 2 and 4 and a delivered notification stay manual. |
| ``` |
| python3 scripts/ppv2-step.py prereq --nlb-arn <nlb> --tg-arn-80 <tg80> --tg-arn-443 <tg443> \ |
| @@ -377,88 +375,87 @@ python3 scripts/ppv2-step.py prereq --nlb-arn <nlb> --tg-arn-80 <tg80> --tg-arn- |
| --record-dir <dir> --profile <profile> --region <region> --targets <i-...,i-...> |
| ``` |
| -Before A80 you can still unwind in reverse: remove the key from the parameters and the fixed boxes, then a target or the bootstrap object may go below vN. |
| +Before A80 you can unwind in reverse: remove the key from the parameters and fixed boxes, then a target or the bootstrap object may go below vN. |
| -### The steps |
| +Needs: the AWS profile must allow `ec2:DescribeNetworkInterfaces`, `ssm:SendCommand` and `ssm:ListCommandInvocations`, plus the target group and alarm reads and the tofu apply. The operator host and the probe host must both be NTP-synced. The tool tolerates 5 s of difference between them. |
| -Run four steps in this order, one NLB at a time: A80, A443, B80, B443. A80 and A443 turn PPv2 on for the `:80` and `:443` target groups. B80 and B443 turn client IP preservation off. `:80` goes first in each pair. |
| +### The steps |
| -For each step, run `apply`, then the probe against both NLB addresses, then `converge`: |
| +Four steps per NLB, in this order: A80, A443 (PPv2 on), B80, B443 (preservation off). `:80` goes first in each pair. Each step starts only when the previous step's record exists and passed. |
| -``` |
| -python3 scripts/ppv2-step.py apply --root <tofu root> --nlb-arn <nlb> --tg-arn <tg> \ |
| - --tg-address <tofu address of the tg> --port <80|443> --step <A80|A443|B80|B443> \ |
| - --record-dir <dir> --profile <profile> --region <region> --targets <i-...,i-...> |
| +`apply` changes one attribute on one target group, then goes straight into convergence. From the apply to the record it polls target health every 10 s and trust counters every 30 s. So the transition is watched the whole time. Run it like this: |
| -python3 scripts/ppv2-probe.py --nlb-ip <one NLB address> --port <80|443> --host <echo host> \ |
| - --path <echo path> --expect-client <probe host public address> \ |
| - --source-ports <lo>-<hi> --expect <s0|s1|s2> --out <record> |
| +1. Start `apply`. It also needs `--probe-records`, two paths, one per NLB public address, that do not exist yet: |
| -python3 scripts/ppv2-step.py converge --step <step> --record-dir <dir> \ |
| - --probe-records <record for address 1>,<record for address 2> --tg-arn <tg> \ |
| - --profile <profile> --region <region> --targets <i-...,i-...> |
| -``` |
| + ``` |
| + python3 scripts/ppv2-step.py apply --root <tofu root> --nlb-arn <nlb> --tg-arn <tg> \ |
| + --tg-address <tofu address of the tg> --port <80|443> --step <A80|A443|B80|B443> \ |
| + --record-dir <dir> --probe-records <new-a.json>,<new-b.json> \ |
| + --profile <profile> --region <region> --targets <i-...,i-...> |
| + ``` |
| +2. When it prints "Converging: start the probes", and not before, start both probes on the probe host, one per public address, each with its own source port range and a fresh record path: |
| -- Run one probe process per NLB address and port, on a host in the NLB's region. Give each process its own `--source-ports` range, so no source port goes to both addresses. |
| -- Use `--expect s0` before A, `--expect s1` after A, and `--expect s2` after B. |
| -- `apply` runs a targeted tofu plan and refuses unless it changes exactly one attribute on exactly one target group. It refuses any move that could pass through S3. A forward step also needs the previous step's record from `converge`. |
| -- Exit codes: 0 done or passed, 1 refused or failed, 2 invalid arguments. |
| -- From `apply` until `converge` writes its record, keep every target healthy in both groups. Run no restart, drain or group roll in that time. Do maintenance between steps. |
| + ``` |
| + python3 scripts/ppv2-probe.py --nlb-ip <public address> --port <80|443> --host <echo host> \ |
| + --path <echo path> --expect-client <probe host public address> \ |
| + --source-ports <lo>-<hi> --expect <s0|s1|s2> --out <new-a.json> |
| + ``` |
| -### Rollback |
| + Use `--expect s0` for A steps, `--expect s1` for B steps. A probe that started before the apply is refused, and so is a stale record file. |
| +3. Leave the probes and `apply` running until `apply` exits. Exit 0 means the step passed and wrote `<step>.json`. Run no restart, drain or group roll until then. Do maintenance between steps. |
| -Rollback ends at S1. Run B443 and then B80 back with the step tool's `R443` and `R80` steps (preservation on). A80 and A443 are never reversed. The edge stays armed and ignores the NLB's header, as in S1. |
| +Exit codes: 0 done or passed, 1 refused or failed, 2 invalid arguments, 130 interrupted. Records are in the record directory. `<step>-polls.jsonl` has every poll. |
| -### The S3 incident procedure |
| +If the run is interrupted, or a convergence fails, or one `aws` call is slow enough to leave more than 15 s between health observations, the window fails. Use `reverify`, not `converge`. It opens a fresh window for a step already made (A steps cannot be undone) with new probes and new record paths: |
| -Run this if the trust-violation alarm fires, or if the probe or a target's counters show `marker_trusted` or `no_client_refused` above zero. Some target group has PPv2 off with preservation off. |
| +``` |
| +python3 scripts/ppv2-step.py reverify --root <tofu root> --nlb-arn <nlb> --tg-arn <tg> \ |
| + --tg-address <tofu address of the tg> --port <80|443> --step <step> \ |
| + --record-dir <dir> --probe-records <new-a.json>,<new-b.json> \ |
| + --profile <profile> --region <region> --targets <i-...,i-...> [--incident-cleared] |
| +``` |
| -1. Raise the barrier on every target in that target group, over SSM, all at once: |
| +`reverify` also adopts the change if a `tofu apply` failed after it began and the target group is now in the step's target state. A reverify's result replaces the step's evidence, pass or fail. `converge` (flags `--step --record-dir --probe-records --tg-arn --profile --region --targets`) exists only to resume a window that was not broken. |
| - ``` |
| - carlos system edge trust-barrier |
| - ``` |
| +B steps refuse while any barrier is up. A and R steps do not. |
| - After this no connection from an NLB node carries a client address, and the forged ones are closed. Health checks still pass. It prints one JSON line with `barrier` and `closed`. |
| -2. Turn preservation on for the affected target group with `aws elbv2 modify-target-group-attributes`. This direct command is allowed only in this direction, and only in an incident or an abort. Reconcile tofu afterwards with a plan that shows no change. |
| -3. Find who turned PPv2 off. Check that the group is back in S1 by running the probe with `--expect s1` on both addresses. Then lower the barrier on every target: |
| +### Rollback |
| - ``` |
| - carlos system edge trust-resume |
| - ``` |
| +Rollback ends at S1. Run `R443` then `R80` with `apply` (preservation on). `--probe-records` is optional for them. A80 and A443 are never reversed. The edge stays armed and ignores the NLB's header, as in S1. |
| - Then go forward again with the step tool, in a window. |
| -4. Report to 8a3d302 with the alarm, the counters and the barrier's close counts. |
| +### The S3 incident procedure |
| -To read a target at any time: |
| +Run this if the trust-violation alarm fires, or the probe or a target's counters show `marker_trusted` or `no_client_refused` above zero. Some target group has PPv2 off with preservation off. |
| -``` |
| -carlos system edge trust-status |
| -``` |
| +1. On every target in that target group, over SSM, all at once: `carlos system edge trust-barrier`. No connection from an NLB node carries a client address after this, and forged ones are closed. Health checks still pass. It prints one JSON line with `barrier` and `closed`. |
| +2. Turn preservation on for the affected target group with `aws elbv2 modify-target-group-attributes`. This is the only direct command allowed, and only in an incident. The group is now in S0 (or S1 if PPv2 was still on). Reconcile tofu afterwards with a plan that shows no change. |
| +3. Find who turned PPv2 off. If the attribute is off, run the A step again with `apply`, while the barrier stays up (A steps allow it). If it is already on, run `reverify` for the A step with `--incident-cleared`. `reverify` refuses after any S3 signal recorded for the step unless you pass the flag, so pass it only once you understand the incident. |
| +4. Check S1 with the probe, `--expect s1`, on both public addresses. |
| +5. On every target: `carlos system edge trust-resume`. |
| +6. Continue with the B steps, in a window. |
| +7. Report to 8a3d302 with the alarm, the counters and the barrier's close counts. |
| -It prints one JSON line: `armed`, `barrier`, the counters and `proxied_by_node`. All three verbs exit 0 on success, 1 when refused or failed, and 2 for bad arguments or a box that is not armed. |
| +To read a target at any time, `carlos system edge trust-status` prints one JSON line with `armed`, `barrier`, the counters and `proxied_by_node`. The three verbs exit 0 on success, 1 when refused or failed, 2 for bad arguments or a box not armed. |
| Notes from the reviews: |
| - `trust-barrier` exits non-zero with `"persisted":false` when it could not write the barrier to disk. The barrier is up in memory but will not survive a restart. Fix the disk and raise it again. |
| - Trust violations in the last partial minute before an agent stop are never published as a metric. After an unexpected stop, read the journal: `journalctl -u carlos-edge -g "proxy protocol:"`. |
| -- A refused boot recovery on a box that has the guard armed keeps the edge down until an operator acts, because its edge unit has `Requires=carlos-system-recover.service`. On a fixed box that includes its EIP traffic. |
| +- A refused boot recovery on a box with the guard armed keeps the edge down until an operator acts, because its edge unit has `Requires=carlos-system-recover.service`. On a fixed box that includes its EIP traffic. |
| ### The floor: nothing below vN on an NLB target |
| -Once A80 is done on a region's NLB, no carlos build older than vN can run on any target of that NLB again. An older edge answers the NLB's header with a 400 or a TLS error, fails its health checks and drops out. If all targets do this at once, it is an outage. A rollback below vN is off the table on those boxes. A rollback to a build at or above vN is fine, and so is a fix forward. |
| - |
| -Today that means dev leo, sophie and the IE members, and flagship adi and the US members, from the day each region does A80. Boxes that are not NLB targets are not affected. |
| +Once A80 is done on a region's NLB, no build older than vN can run on any target of that NLB again. An older edge answers the NLB's header with a 400 or a TLS error and fails its health checks. If all targets do this at once, it is an outage. Rollback to any build at or above vN is fine, and so is a fix forward. Boxes that are not NLB targets are not affected. Today that means dev leo, sophie and the IE members, and flagship adi and the US members, from each region's A80. |
| -The box enforces this. A box whose host.env has `CARLOS_INGRESS_PROXY_SOURCES` refuses to activate a binary that does not report `ingress-proxy-v2` in `carlos version --json`, and keeps the running binary. The recovery unit makes the same check on `/opt/carlos/carlos.prev` with `carlos system proxy-allows-prev /opt/carlos/carlos.prev` (exit 0 allowed or not armed, 1 refused, 2 bad arguments). A member launched from a template below vN fails its boot. |
| +The box enforces it. A box whose host.env has `CARLOS_INGRESS_PROXY_SOURCES` refuses to activate a binary that does not report `ingress-proxy-v2` in `carlos version --json`, and keeps the running binary. The recovery unit makes the same check with `carlos system proxy-allows-prev /opt/carlos/carlos.prev` (exit 0 allowed or not armed, 1 refused, 2 bad arguments). A member launched from a template below vN fails its boot. |
| -The release recipe must do this before it promotes a build to a channel (canary or stable), changes a region's bootstrap object, or re-pins a group launch template: |
| +The release recipe, before it promotes a build to a channel, changes a region's bootstrap object, or re-pins a launch template: |
| -- Read `proxy_protocol_v2.enabled` on every region NLB target group of the deployment, read-only, with `aws elbv2 describe-target-group-attributes`. |
| -- If any is `true`, refuse any build below vN. Do not re-promote an old build as a quick rollback. Cut forward. |
| -- Record in the state line, per deployment: "PPv2 on since <date>: floor vN". |
| +- Reads `proxy_protocol_v2.enabled` on every region NLB target group of the deployment (`aws elbv2 describe-target-group-attributes`, read-only). |
| +- If any is `true`, refuses builds below vN. No re-promoting an old build as a quick rollback; cut forward. |
| +- Records per deployment: "PPv2 on since <date>: floor vN". |
| -The roll card must do this: |
| +The roll card: |
| -- Before the roll, make the same read for each region. For each region with PPv2 on, list its NLB targets and write: "rollback below vN is off the table on these boxes; rollback target is <build at or above vN> or forward fix". The rollback section names that build. It never says "the previous release" unchecked. |
| -- After the roll, check that every NLB target shows the armed line with the module's addresses, and that the trust-violation alarm is OK. |
| +- Before the roll, makes the same read per region. For each region with PPv2 on it lists the NLB targets and states: "rollback below vN is off the table on these boxes; rollback target is <build at or above vN> or forward fix". The rollback section names that build. |
| +- After the roll, checks every NLB target shows the armed line with the module's addresses and the trust-violation alarm is OK. |