carlos / platform Public

docs: region HA runbook, PPv2 cutover and the vN floor

New section on the region NLBs: prerequisites, the step tool, rollback to
S1, the S3 incident procedure, and the vN floor for releases and rolls.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev fd2863f9f48c817a6a4064fbb43e43a680378946 parent 900852a
1 file changed, +119 −0
  • docs/region-ha-runbook.md +119 −0
diff --git a/docs/region-ha-runbook.md b/docs/region-ha-runbook.md
index 21061beea..5cbfe913d 100644
--- a/docs/region-ha-runbook.md
+++ b/docs/region-ha-runbook.md
@@ -343,3 +343,122 @@ To restore the previous time daemon, run NEEDRESTART_MODE=l DEBIAN_FRONTEND=noni
Do not continue to G3 step 4 after a failed check.
For new fixed boxes, have the deployment's host-init copy the reviewed `scripts/region-ha-g3/chrony-fixed-box.sh` to the box and run it with `</dev/null` after the `carlos` account and `/etc/carlos` exist. Do not apply that user_data change to running boxes, and never re-run user_data on a live box. A user_data change in the flagship root can stop and start the box. Keep this first-boot change separate from the attended convergence above.
+
+## PROXY protocol v2 on the region NLBs
+
+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:
+
+- **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.
+
+The only moves are S0 to S1, S1 to S2 and S2 to S1. Nothing turns PPv2 off.
+
+### Prerequisites, per NLB
+
+Do these in order. A target is a fixed box or a group member.
+
+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.
+
+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:
+
+```
+python3 scripts/ppv2-step.py prereq --nlb-arn <nlb> --tg-arn-80 <tg80> --tg-arn-443 <tg443> \
+ --sources <module proxy_protocol_sources> --alarm <trust alarm name> \
+ --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.
+
+### The steps
+
+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.
+
+For each step, run `apply`, then the probe against both NLB addresses, then `converge`:
+
+```
+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-...>
+
+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>
+
+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-...>
+```
+
+- 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.
+
+### Rollback
+
+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.
+
+### The S3 incident procedure
+
+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.
+
+1. Raise the barrier on every target in that target group, over SSM, all at once:
+
+ ```
+ carlos system edge trust-barrier
+ ```
+
+ 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:
+
+ ```
+ carlos system edge trust-resume
+ ```
+
+ 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.
+
+To read a target at any time:
+
+```
+carlos system edge trust-status
+```
+
+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.
+
+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.
+
+### 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.
+
+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 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:
+
+- 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".
+
+The roll card must do this:
+
+- 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.