carlos / platform Public

docs: narrow the runbook's drain claims to what the spec promises

Astra task review round 1. withdrawn is what the target groups reported,
and zero errors is a measured target; the runbook now lists the spec §3
exclusions (all hosts the box holds, incomplete headers at close, requests
past the 30 s wait, long-lived streams). The retention prefix also covers
reader and attribute-read failures. A socket that does not answer can mean
the box is not set up for the drain, not only a stopped edge. Recovery's
systemctl restart still runs the drain unit's stop.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev e62afc454181a6feb33c837fc928bb86b9ddd88c parent 1e6f138
1 file changed, +17 −7
  • docs/region-ha-runbook.md +17 −7

Intent

Attributed to this commit: 8.13 g CO₂e (1,045,521 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on w6-ingress-drain, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.

diff --git a/docs/region-ha-runbook.md b/docs/region-ha-runbook.md
index 9df34a0ab..17fd9c5aa 100644
--- a/docs/region-ha-runbook.md
+++ b/docs/region-ha-runbook.md
@@ -22,7 +22,7 @@ Named-pool creates need a serving box that reports membership of the requested p
## Settings in host.env
-A fixed box is one you created by hand, not through Auto Scaling. It reads its region HA settings from root-owned `/etc/carlos/host.env`, mode 0600. The region-host module does not write that file. Write the lines, then restart `carlos-edge.service` on one box at a time. A restart costs about 1 to 11 seconds of held or refused requests on that box. On a box attached to a load balancer with its ingress drain set up, a restart takes longer and should cost no failed requests through the load balancer (see [Restarting a fixed box](#restarting-a-fixed-box)).
+A fixed box is one you created by hand, not through Auto Scaling. It reads its region HA settings from root-owned `/etc/carlos/host.env`, mode 0600. The region-host module does not write that file. Write the lines, then restart `carlos-edge.service` on one box at a time. A restart costs about 1 to 11 seconds of held or refused requests on that box. On a box attached to a load balancer with its ingress drain set up, a restart takes longer and aims to cost no failed requests through the load balancer, apart from the cases listed in [Restarting a fixed box](#restarting-a-fixed-box). That target is measured, not proven.
```
CARLOS_REGION_HA=1
@@ -190,7 +190,7 @@ Expect a planned stop to take 30 to 60 seconds longer than before, and up to abo
These stops are **not** drained, and behave as before:
- The first roll onto a release with the drain. The agent being stopped is the old one, which has no drain. The verb logs that the agent has no ingress drain and carries on. So does any automatic rollback during that first roll.
-- Recovery of an interrupted or failed self-update (`carlos-system-recover.service`). It does not ask for the drain, because the edge has usually already stopped by then. Treat it as undrained.
+- Recovery of an interrupted or failed self-update (`carlos-system-recover.service`). The recovery verb itself does not ask for the drain, because the edge has usually already stopped by then. It restarts the edge with systemctl, so if the edge is still running and `carlos-edge-drain.service` is active, that unit's stop runs the drain as for any restart, using the binary then on disk. If that binary has no drain, nothing is drained.
- Crashes, `systemctl kill`, and an instance that dies. The load balancer notices only after two failed health checks, about 20 seconds.
### Reading the result
@@ -216,19 +216,29 @@ The agent also logs one line in `journalctl -u carlos-edge`, starting `agent: in
The `result` can be:
- `done`: the drain ran. Read the verdict.
-- `not_armed`: this box has no drain, and the stop went ahead as before. The reason says why: region HA is off, `CARLOS_INGRESS_TARGET_GROUPS` is not set, or a target group it names is not in the box's own account and region.
+- `not_armed`: this box has the drain set up but could not run it, and the stop went ahead as before. The reason says why, for example a target group it names is not in the box's own account and region, the box's instance ID is not known, or the edge is not running.
- `group_member`: the box is a group member. Expected; members leave through `carlos system group`.
- `refused`: the drain did not start, usually because a region HA connection drain was already running. The stop went ahead as before.
-Other summary lines, with no report, mean nothing was drained: `the agent's drain socket is not answering` (the edge had already stopped), and `the agent has no ingress drain (an older release)`.
+Other summary lines, with no report, mean nothing was drained:
+
+- `the agent's drain socket is not answering`: no agent answered. The edge may already have stopped, or the box is not set up for the drain at all: a fixed box with region HA off, or with no `CARLOS_INGRESS_TARGET_GROUPS`, does not serve the drain socket, so it gives this line rather than `not_armed`. Check host.env and `journalctl -u carlos-edge` before concluding which.
+- `the agent has no ingress drain (an older release)`.
### The verdict
-`withdrawn` is the good case. Every target group stopped sending the box new connections, another target was healthy, and that held for 10 seconds before the listeners closed. Expect no failed requests through the load balancer, apart from requests for the box's own fixed hosts.
+`withdrawn` is the good case. The box read every target group reporting it `unhealthy` or `unhealthy.draining`, with another target `healthy`, and that held for a further 10 seconds before the listeners closed. That is what the target groups reported, not proof that no load balancer node sent a new connection afterwards: AWS documents no bound on how long its nodes take to act on that state. The aim is no failed requests through the load balancer, and it is measured, not proven. Even with `withdrawn`, these can still fail, as they did before the drain:
+
+- requests for any host the restarting box holds, fixed or HA. Its fixed hosts are down for the restart, and peers answer 503 `Retry-After: 10` for its HA hosts until they move;
+- a connection the box had accepted whose request headers had not all arrived when the listeners closed. It is closed without an answer;
+- requests still running at the end of the 30-second wait, such as slow uploads or downloads;
+- long-lived streams (server-sent events, WebSockets) still open at the end of the wait. They are closed and reconnect through the load balancer to another box.
`unverified` means the drain could not confirm that. It still closed the listeners and let the stop go ahead, because a stop is never held up. Clients may see a few errors, as before the drain existed. The reasons after the colon in the summary line say why:
-- `target group retention: ...`: a target group resets connections when a target turns unhealthy, or keeps them for less than 180 seconds. The target group attributes are not applied yet. Apply them (next section).
+- `target group retention: ...`: the drain could not confirm that the target groups keep open connections long enough. Two different causes share this prefix, so read the rest of the line before changing any infrastructure:
+ - `target group retention: target group <arn>: unhealthy connection termination is on` or `... draining interval ... is below 3m0s`: the attributes are not applied. Apply them (next section).
+ - `target group retention: target health reader: ...` or another error after the prefix: the box could not build its reader or read the attributes, for example missing read rights or an AWS error. The attributes may be fine; fix what the error names.
- `not healthy at start: target group <arn> reports <state>`: the box was already not healthy when the drain began, so the drain cannot tell how long it has been that way.
- `target group <arn> reports healthy` (or `initial`): after 90 seconds the target group still had not marked the box unhealthy.
- `no other healthy target: target group <arn>`: the box was the last healthy target. When every target is unhealthy the load balancer fails open and keeps sending traffic to all of them, so draining this box protected nobody. Bring another target into service before you restart this one.
@@ -241,7 +251,7 @@ After the listeners close, the box serves nothing on its public ports. If the ag
### Setting it up on a deployment
-Do these steps in this order, on the deployment's card. Until step 3, the drain answers `not_armed` and every stop behaves as before.
+Do these steps in this order, on the deployment's card. Until step 3, the box has no drain and every stop behaves as before; the drain unit logs `the agent's drain socket is not answering`.
1. Apply the region-host module with the target group attributes (unhealthy connection termination off, a 180-second draining interval) and, for the fixed box, `ingress_target_group_arns` set to the target groups it is attached to. This gives the box's role the read-only `elasticloadbalancing:DescribeTargetHealth` and `DescribeTargetGroupAttributes`. No target is re-registered.
2. Check every target group: