carlos / platform Public

ppv2-step: watch both TGs from before apply; per-port B evidence

From the whole-branch review (fix-wave W9-W13):
- apply, converge and reverify take --tg-arn-80 and --tg-arn-443 and
  poll both groups' health every 10 s from just after the intent record,
  through tofu apply, to the verdict; continuity anchors at the intent's
  started_at; any unhealthy target in either group fails the step.
- B steps converge on the changed port's by_listener proxied_by_node;
  STILL counters are also checked on that listener.
- A changed edge_instance, or any count lower than at the previous poll,
  fails the window as a restart.
- prereq checks the installed guard binary on every target over SSM.
- New sync-tfvars rewrites the tfvars file to live under the lock and
  never writes S3.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev d7a06976a059b627f4af8b4f53bd92aaa4c1846e parent f6313b2
3 files changed, +665 −99
  • scripts/ppv2-step.py +339 −75
  • scripts/ppv2_step_test.py +312 −13
  • scripts/testdata/ppv2/trust-status.json +14 −11
diff --git a/scripts/ppv2-step.py b/scripts/ppv2-step.py
index 6cb6d47e0..79e7c1478 100755
--- a/scripts/ppv2-step.py
+++ b/scripts/ppv2-step.py
@@ -15,14 +15,18 @@ them changes PPv2 while preservation is off, so no node can pass through S3.
prereq the automated part of the prerequisites (spec 6.1): both target
groups in S0, every target armed with the NLB's node addresses,
- barrier down, the trust alarm OK. Writes prereq.json with the
- NLB's public addresses. Versions, the bootstrap object hash and a
+ barrier down, the trust alarm OK, and on every target the
+ installed guard binary (/opt/carlos/system/guard/carlos) absent
+ or reporting ingress-proxy-v2. Writes prereq.json with the NLB's
+ public addresses. Versions, the bootstrap object hash and a
delivered alarm notification are still checked by hand.
apply makes one step on one target group through a targeted tofu plan,
writes <step>-applied.json, then goes straight into convergence:
- it polls target health every 10 s and trust counters every 30 s
- until the probe records are in, and writes <step>.json, the next
- step's evidence. Forward steps need --probe-records.
+ it polls target health in BOTH target groups every 10 s, from
+ just after <step>-intent.json is written (before tofu apply
+ starts) to the verdict, and trust counters every 30 s until the
+ probe records are in, and writes <step>.json, the next step's
+ evidence. Forward steps need --probe-records.
converge resumes the convergence of the latest apply (or reverify) of a
step, after an interruption. Polls already made for it count, and
a failure already seen is never cleared.
@@ -38,6 +42,20 @@ them changes PPv2 while preservation is off, so no node can pass through S3.
--incident-cleared. Each step binds to the latest of its
predecessor's apply, reverify and intent: an intent newer than
the evidence makes it stale until a reverify passes.
+ sync-tfvars
+ rewrites ppv2.auto.tfvars.json to both target groups' live
+ attributes, under the lock: after the S3 incident procedure's
+ direct preservation-on command, the file disagrees with live and
+ every step refuses until it matches. Refuses while either group
+ is in S3.
+
+Every apply, converge and reverify names both target groups (--tg-arn-80,
+--tg-arn-443; each checked against the NLB and its port) and watches both:
+an unhealthy target in either group at any poll fails the step (spec 6.4).
+A step also fails when a target's edge restarts during it: its trust-status
+edge_instance changes, or any counter falls from one poll to the next. B
+steps converge on the changed port's own per-listener counts (by_listener),
+never on the other listener's traffic.
Steps: A80, A443 (PPv2 on), B80, B443 (preservation off), R443, R80
(preservation back on). Nothing turns PPv2 off; there is no step for it.
@@ -96,6 +114,15 @@ COUNTERS = ('proxied', 'no_client', 'no_client_refused', 'ignored', 'ignored_pri
STILL = ('malformed', 'timeout', 'ignored_private', 'marker_trusted', 'no_client_refused')
PROBE_EXPECT = {'A': 's1', 'B': 's2', 'R': 's1'}
TRUST_STATUS = '/opt/carlos/carlos system edge trust-status'
+LISTENERS = ('80', '443')
+TRUST_KEYS = {'armed', 'barrier', 'edge_instance', 'counters', 'proxied_by_node', 'by_listener'}
+# The guard binary guard-arm installs; app updates do not refresh it, and an
+# old one's `guard-exec recover` has no PPv2 gate (spec 6.1).
+GUARD_BINARY = '/opt/carlos/system/guard/carlos'
+GUARD_ABSENT = 'ppv2-step: guard binary absent'
+GUARD_CHECK = (f'g={GUARD_BINARY}; if [ -e "$g" ] || [ -L "$g" ]; then "$g" version --json; '
+ f"else echo '{GUARD_ABSENT}'; fi")
+FEATURE = 'ingress-proxy-v2'
ARMED_LINE = 'edge: proxy protocol: armed on'
JOURNAL = "journalctl -u carlos-edge.service -o cat --no-pager | grep -F '%s' | tail -n 1" % ARMED_LINE
ARMED_RE = re.compile(r'edge: proxy protocol: armed on :80 and :443, trusting (\S+), barrier (up|down)')
@@ -251,8 +278,18 @@ def plan_refusal(plan, address, attribute, before, after):
return None
+def counts_ok(counters, nodes):
+ if not isinstance(counters, dict) or set(counters) != set(COUNTERS):
+ return False
+ if not all(type(v) is int and v >= 0 for v in counters.values()):
+ return False
+ return isinstance(nodes, dict) and all(isinstance(k, str) and type(v) is int and v >= 0 for k, v in nodes.items())
+
+
def parse_trust(text):
- """The trust-status line in text, validated, or None."""
+ """The trust-status line in text, validated, or None: every field present,
+ and armed, a non-empty edge_instance and exactly the two listeners, whose
+ counts sum to the line's own."""
lines = [line for line in (text or '').splitlines() if line.strip()]
if not lines:
return None
@@ -260,16 +297,30 @@ def parse_trust(text):
doc = json.loads(lines[-1])
except ValueError:
return None
- if not isinstance(doc, dict) or set(doc) != {'armed', 'barrier', 'counters', 'proxied_by_node'}:
+ if not isinstance(doc, dict) or set(doc) != TRUST_KEYS:
return None
if not isinstance(doc['armed'], bool) or not isinstance(doc['barrier'], bool):
return None
- counters, nodes = doc['counters'], doc['proxied_by_node']
- if not isinstance(counters, dict) or set(counters) != set(COUNTERS):
+ if not counts_ok(doc['counters'], doc['proxied_by_node']):
return None
- if not all(type(v) is int and v >= 0 for v in counters.values()):
+ instance, listeners = doc['edge_instance'], doc['by_listener']
+ if not isinstance(instance, str) or not isinstance(listeners, dict):
return None
- if not isinstance(nodes, dict) or not all(isinstance(k, str) and type(v) is int and v >= 0 for k, v in nodes.items()):
+ if not doc['armed']:
+ return doc if instance == '' and listeners == {} else None
+ if not instance or set(listeners) != set(LISTENERS):
+ return None
+ for port in LISTENERS:
+ l = listeners[port]
+ if not isinstance(l, dict) or set(l) != set(COUNTERS) | {'proxied_by_node'}:
+ return None
+ if not counts_ok({c: l[c] for c in COUNTERS}, l['proxied_by_node']):
+ return None
+ if any(doc['counters'][c] != sum(listeners[p][c] for p in LISTENERS) for c in COUNTERS):
+ return None
+ nodes = set(doc['proxied_by_node']).union(*(listeners[p]['proxied_by_node'] for p in LISTENERS))
+ if any(doc['proxied_by_node'].get(n, 0) != sum(listeners[p]['proxied_by_node'].get(n, 0) for p in LISTENERS)
+ for n in nodes):
return None
return doc
@@ -408,13 +459,22 @@ class Cloud:
"""{instance: trust-status dict, or a string saying why there is none}."""
return {iid: trust_of(iid, *answer) for iid, answer in self.ssm(targets, TRUST_STATUS).items()}
- def tofu(self, root, *args):
+ def tofu(self, root, *args, tick=None):
+ """tick, when given, is called about every TICK seconds while tofu runs
+ (the health watch through tofu apply)."""
# Its own session, so a terminal Ctrl-C reaches only this script, which
# then stops tofu with SIGINT (never SIGKILL: that can strand a state lock).
proc = subprocess.Popen(['tofu', f'-chdir={root}', *args], stdout=subprocess.PIPE, stderr=subprocess.PIPE,
stdin=subprocess.DEVNULL, text=True, start_new_session=True)
try:
- out, err = proc.communicate()
+ while True:
+ if tick is not None:
+ tick()
+ try:
+ out, err = proc.communicate(timeout=None if tick is None else TICK)
+ break
+ except subprocess.TimeoutExpired:
+ continue # retrying communicate loses no output
except BaseException:
proc.send_signal(signal.SIGINT)
try:
@@ -567,13 +627,23 @@ def prereq_for(record_dir, nlb_arn):
return prereq
-def tfvars_check(doc, port, live):
+def tfvars_shape(doc):
+ """Why doc is not the file's shape (both keys, true or false for exactly "80" and "443"), or None."""
if not isinstance(doc, dict) or set(doc) != set(TFVARS_KEY.values()):
return f'{TFVARS_FILE} must hold exactly {", ".join(sorted(TFVARS_KEY.values()))}'
- for attribute, key in TFVARS_KEY.items():
+ for key in TFVARS_KEY.values():
values = doc[key]
if not isinstance(values, dict) or set(values) != {'80', '443'} or not all(isinstance(v, bool) for v in values.values()):
return f'{TFVARS_FILE} {key} must set true or false for exactly "80" and "443"'
+ return None
+
+
+def tfvars_check(doc, port, live):
+ reason = tfvars_shape(doc)
+ if reason:
+ return reason
+ for attribute, key in TFVARS_KEY.items():
+ values = doc[key]
if values[port] != live[attribute]:
return (f'{TFVARS_FILE} {key}["{port}"] is {norm(values[port])}, which disagrees with the live '
f'target group ({norm(live[attribute])}); reconcile it before any step')
@@ -612,6 +682,28 @@ def target_list(text):
return targets
+def groups_of(args):
+ """{'80': arn, '443': arn}: both target groups, which every step watches."""
+ groups = {'80': args.tg_arn_80, '443': args.tg_arn_443}
+ if groups['80'] == groups['443']:
+ raise Refused('--tg-arn-80 and --tg-arn-443 name the same target group')
+ return groups
+
+
+def check_groups(cloud, groups, nlb_arn):
+ """Each group is attached to the NLB, on its own port."""
+ for port in LISTENERS:
+ cloud.target_group(groups[port], nlb_arn, port)
+
+
+def health_refusals(cloud, groups, targets):
+ """registered_refusals for every target in both groups, each naming its group."""
+ reasons = []
+ for port in LISTENERS:
+ reasons.extend(f'in the :{port} target group, {r}' for r in registered_refusals(cloud.health(groups[port]), targets))
+ return reasons
+
+
def pending_intent(record_dir, step):
intent = intent_pending(record_dir, step)
if intent:
@@ -656,11 +748,13 @@ def cmd_reverify(args, cloud):
for d, flag in ((record_dir, '--record-dir'), (root, '--root')):
if not d.is_dir():
raise Refused(f'{flag} {d} is not a directory')
+ groups = groups_of(args)
+ args.tg_arn = groups[args.port]
targets = target_list(args.targets)
paths = split(args.probe_records)
with locked(root, record_dir):
check_state_address(cloud, args)
- cloud.target_group(args.tg_arn, args.nlb_arn, args.port)
+ check_groups(cloud, groups, args.nlb_arn)
live = cloud.attributes(args.tg_arn)
state = state_of(live['preserve_client_ip'], live['proxy_protocol_v2'])
if state != step.target:
@@ -715,13 +809,14 @@ def cmd_reverify(args, cloud):
reason = tfvars_check(doc, args.port, live)
if reason:
raise Refused(reason)
- reasons = registered_refusals(cloud.health(args.tg_arn), targets)
+ reasons = health_refusals(cloud, groups, targets)
if reasons:
- raise Refused('every target must be registered and healthy: ' + '; '.join(reasons))
+ raise Refused('every target must be registered and healthy in both target groups: ' + '; '.join(reasons))
baseline_at, baseline = collect_baseline(cloud, step, targets)
verified_at = cloud.clock.time()
verified = {
- 'nlb_arn': args.nlb_arn, 'port': args.port, 'step': args.step, 'tg_arn': args.tg_arn,
+ 'nlb_arn': args.nlb_arn, 'port': args.port, 'step': args.step, 'tg_arn': args.tg_arn, 'tg_arns': groups,
+ 'polls_anchor': iso(verified_at), 'health_from': iso(verified_at),
'tg_address': args.tg_address, 'targets': targets, 'from': step.source, 'to': step.target,
'baseline': baseline, 'baseline_at': iso(baseline_at), 'verified_at': iso(verified_at),
'applied_at': (applied or {}).get('applied_at'),
@@ -743,6 +838,8 @@ def cmd_apply(args, cloud):
for d, flag in ((record_dir, '--record-dir'), (root, '--root')):
if not d.is_dir():
raise Refused(f'{flag} {d} is not a directory')
+ groups = groups_of(args)
+ args.tg_arn = groups[args.port]
targets = target_list(args.targets)
paths = split(args.probe_records) if args.probe_records else None
if step.forward and not paths:
@@ -750,7 +847,7 @@ def cmd_apply(args, cloud):
with locked(root, record_dir):
# Before anything else: the address names the target group we were given.
check_state_address(cloud, args)
- cloud.target_group(args.tg_arn, args.nlb_arn, args.port)
+ check_groups(cloud, groups, args.nlb_arn)
live = cloud.attributes(args.tg_arn)
reason = step_refusal(args.step, live)
if reason:
@@ -762,9 +859,9 @@ def cmd_apply(args, cloud):
public = prereq_for(record_dir, args.nlb_arn)['public_addresses']
if len(paths) != len(public):
raise Refused(f'--probe-records needs one record per NLB address ({len(public)}: {", ".join(public)})')
- reasons = registered_refusals(cloud.health(args.tg_arn), targets)
+ reasons = health_refusals(cloud, groups, targets)
if step.forward and reasons:
- raise Refused('every target must be registered and healthy: ' + '; '.join(reasons))
+ raise Refused('every target must be registered and healthy in both target groups: ' + '; '.join(reasons))
baseline_at, baseline = collect_baseline(cloud, step, targets)
tfvars = root / TFVARS_FILE
try:
@@ -793,7 +890,7 @@ def cmd_apply(args, cloud):
reason = plan_refusal(plan, args.tg_address, step.attribute, live[step.attribute], step.value)
if reason:
raise Refused(reason)
- intent = {'step': args.step, 'nlb_arn': args.nlb_arn, 'port': args.port, 'tg_arn': args.tg_arn,
+ intent = {'step': args.step, 'nlb_arn': args.nlb_arn, 'port': args.port, 'tg_arn': args.tg_arn, 'tg_arns': groups,
'tg_address': args.tg_address, 'attribute': step.attribute, 'before': live[step.attribute],
'after': step.value, 'from': step.source, 'to': step.target, 'started_at': iso(cloud.clock.time()),
'planfile': planfile, 'tfvars_before': original.decode(), 'tfvars_after': edited.decode(),
@@ -813,8 +910,14 @@ def cmd_apply(args, cloud):
# From here the file keeps the new value and the intent stays: once tofu
# apply has started the attribute may have changed, and a file put back
# would ask the next ordinary plan to undo it.
+ # Both groups' health from here (just after the intent's started_at,
+ # before tofu apply starts) to the verdict, every poll logged under the
+ # intent's started_at so a resume after any interruption reads them.
+ log = PollLog(record_dir / f'{args.step}-polls.jsonl', intent['started_at'])
+ watch = HealthWatch(cloud, log, groups)
try:
- result = cloud.tofu(root, 'apply', '-input=false', planfile)
+ watch.due()
+ result = cloud.tofu(root, 'apply', '-input=false', planfile, tick=watch.due)
finally:
PHASE['name'] = 'idle'
remove_quietly(root / planfile)
@@ -829,7 +932,8 @@ def cmd_apply(args, cloud):
supersede(record_dir, SUPERSEDES.get(args.step), iso(applied_at))
applied = {
'nlb_arn': args.nlb_arn, 'port': args.port, 'step': args.step, 'applied_at': iso(applied_at),
- 'tg_arn': args.tg_arn, 'tg_address': args.tg_address, 'targets': targets,
+ 'tg_arn': args.tg_arn, 'tg_arns': groups, 'polls_anchor': intent['started_at'],
+ 'health_from': intent['started_at'], 'tg_address': args.tg_address, 'targets': targets,
'from': step.source, 'to': step.target, 'baseline': baseline, 'baseline_at': iso(baseline_at),
'intent_started_at': intent['started_at']}
write_record(record_dir / f'{args.step}-applied.json', applied)
@@ -839,7 +943,7 @@ def cmd_apply(args, cloud):
if not paths:
return 0
print(f'Converging: start the probes on {len(paths)} NLB addresses now; waiting for {", ".join(paths)}.')
- return converge(cloud, record_dir, applied, paths, args.timeout)
+ return converge(cloud, record_dir, applied, paths, args.timeout, watch=watch)
def restore(path, original):
@@ -893,6 +997,36 @@ class PollLog:
return entry
+class HealthWatch:
+ """Both target groups' health every HEALTH_EVERY seconds (spec 6.4: every
+ target healthy in both groups from the start of the step until its record
+ is written), each poll logged as it is made. A poll that fails is logged
+ as an error, which leaves a gap the verdict refuses; it never raises."""
+
+ def __init__(self, cloud, log, groups):
+ self.cloud, self.log, self.groups = cloud, log, groups
+ self.next = cloud.clock.time()
+
+ def poll(self):
+ for port in LISTENERS:
+ t = self.cloud.clock.time()
+ entry = {'kind': 'health', 'port': port, 'tg_arn': self.groups[port], 'at': iso(t)}
+ try:
+ entry['health'] = self.cloud.health(self.groups[port])
+ except Refused as err:
+ entry['error'] = str(err)
+ except Exception as err: # an observation missed, not a crash mid-apply
+ entry['error'] = f'{type(err).__name__}: {one_line(err)}'
+ self.log.add(entry)
+
+ def due(self):
+ """Health keeps its own 10 s schedule through every wait, until the record is written."""
+ now = self.cloud.clock.time()
+ if now >= self.next:
+ self.poll()
+ self.next = now + HEALTH_EVERY
+
+
class TrustJob:
"""One trust-status poll that does not block the health schedule."""
@@ -943,8 +1077,9 @@ def probes_ready(paths, clock):
return all(f is None or clock.time() >= f for f in finishes)
-def converge(cloud, record_dir, applied, paths, timeout):
- """Polls until the probe records are in, then writes <step>.json. Returns the exit code."""
+def converge(cloud, record_dir, applied, paths, timeout, watch=None):
+ """Polls until the probe records are in, then writes <step>.json. Returns the exit code.
+ watch is apply's HealthWatch, kept on its schedule; a resume makes its own."""
step, clock = applied['step'], cloud.clock
prereq = prereq_for(record_dir, applied['nlb_arn'])
if len(paths) != len(prereq['public_addresses']):
@@ -954,15 +1089,13 @@ def converge(cloud, record_dir, applied, paths, timeout):
prior = load_record(record_dir / f'{step}.json')
if prior and record_anchor(prior) == anchor and prior.get('passed') is True:
raise Refused(f'{step}.json already passed for the {anchor_kind(applied)} at {anchor}; nothing to resume')
- log = PollLog(record_dir / f'{step}-polls.jsonl', anchor)
+ groups = applied.get('tg_arns') or {}
+ if set(groups) != set(LISTENERS) or groups.get(applied['port']) != applied['tg_arn']:
+ raise Refused(f"the {anchor_kind(applied)} record of {step} does not name both target groups; "
+ 'reverify the step with this version')
+ log = PollLog(record_dir / f'{step}-polls.jsonl', applied.get('polls_anchor') or anchor)
targets = applied['targets']
-
- def poll_health():
- t = clock.time()
- try:
- log.add({'kind': 'health', 'at': iso(t), 'health': cloud.health(applied['tg_arn'])})
- except Refused as err:
- log.add({'kind': 'health', 'at': iso(t), 'error': str(err)})
+ watch = watch or HealthWatch(cloud, log, groups)
def poll_state():
t = clock.time()
@@ -973,14 +1106,7 @@ def converge(cloud, record_dir, applied, paths, timeout):
log.add({'kind': 'state', 'at': iso(t), 'error': str(err)})
deadline = clock.time() + timeout
- schedule = {'health': clock.time()}
-
- def health_due():
- """Health keeps its own 10 s schedule through every wait, until the record is written."""
- now = clock.time()
- if now >= schedule['health']:
- poll_health()
- schedule['health'] = now + HEALTH_EVERY
+ health_due = watch.due
def log_trust(job):
"""Logs a trust poll with any S3 signal it shows against this run's
@@ -1015,7 +1141,7 @@ def converge(cloud, record_dir, applied, paths, timeout):
break
health_due()
poll_state()
- poll_health()
+ watch.poll()
except Interrupted as err:
raise Interrupted(f'{err} during convergence of {step}; no verdict written; the polls so far are kept in '
f'{log.path.name}; resume with converge')
@@ -1031,8 +1157,8 @@ def converge(cloud, record_dir, applied, paths, timeout):
record = dict(summary, nlb_arn=applied['nlb_arn'], port=applied['port'], step=step, tg_arn=applied['tg_arn'],
applied_at=applied.get('applied_at'), verified_at=applied.get('verified_at'),
converged_at=iso(clock.time()), passed=passed, reasons=reasons, history=history,
- targets=targets, polls=log.path.name,
- proxied_scope='proxied_by_node sums both listeners (:80 and :443)')
+ targets=targets, polls=log.path.name, tg_arns=groups,
+ proxied_scope=f"B steps converge on by_listener[{applied['port']}].proxied_by_node: the changed port only")
write_record(record_dir / f'{step}.json', record)
if passed:
print(f'{step} converged; {step}.json passed')
@@ -1175,7 +1301,36 @@ def continuous_reasons(times, start, end, gap, what, start_label):
return reasons
-def trust_findings(status, base, iid, step):
+def counts_of(status):
+ """Every count in a status line that only rises while one edge runs: the
+ sums, each listener's, and each node's proxied count, sum and per listener."""
+ out = {(None, c): status['counters'][c] for c in COUNTERS}
+ out.update({(None, 'node ' + n): v for n, v in status['proxied_by_node'].items()})
+ for port, listener in (status.get('by_listener') or {}).items():
+ out.update({(port, c): listener[c] for c in COUNTERS})
+ out.update({(port, 'node ' + n): v for n, v in listener['proxied_by_node'].items()})
+ return out
+
+
+def restart_reasons(iid, before, now, since):
+ """The edge restarted between two status lines: another edge_instance, or
+ any count lower than before (a reset to zero that has not caught up)."""
+ if before.get('edge_instance') != now.get('edge_instance'):
+ return [f"{iid}: edge_instance changed from {before.get('edge_instance')} to {now.get('edge_instance')} "
+ f'since {since}: the edge restarted during the step']
+ reasons, got = [], counts_of(now)
+ for (port, name), was in counts_of(before).items():
+ if got.get((port, name), 0) < was:
+ label = f'proxied from {name}' if name.startswith('node ') else name
+ where = '' if port is None else f' on :{port}'
+ reasons.append(f'{iid}: {label}{where} fell from {was} to {got.get((port, name), 0)} since {since}: '
+ 'the edge restarted during the step')
+ return reasons
+
+
+def trust_findings(status, base, prev, iid, step):
+ """One poll's findings for one target, against the run's baseline and the
+ target's previous status line in this run (prev: (at, status) or None)."""
if isinstance(status, str):
return [] # no answer at all (SSM): not an observation; the final poll must have one
reasons = []
@@ -1187,18 +1342,26 @@ def trust_findings(status, base, iid, step):
reasons.append(f'{iid}: barrier is up')
if not is_status(status):
return reasons
+ if prev is not None:
+ reasons.extend(restart_reasons(iid, prev[1], status, f'the poll at {prev[0]}'))
if not is_status(base):
return reasons + [f'{iid}: the apply recorded no baseline ({base})']
- for counter in COUNTERS:
- if status['counters'][counter] < base['counters'][counter]:
- reasons.append(f"{iid}: {counter} fell from {base['counters'][counter]} to {status['counters'][counter]}: "
- 'the edge restarted during the step')
+ reasons.extend(restart_reasons(iid, base, status, 'the baseline'))
+ port = STEPS[step].port
+ was_l, now_l = listener_of(base, port), listener_of(status, port)
for counter in STILL:
if status['counters'][counter] > base['counters'][counter]:
reasons.append(f"{iid}: {counter} moved from {base['counters'][counter]} to {status['counters'][counter]}")
+ if was_l and now_l and now_l[counter] > was_l[counter]:
+ reasons.append(f'{iid}: {counter} on :{port}, the changed port, moved from {was_l[counter]} to {now_l[counter]}')
return reasons
+def listener_of(status, port):
+ """A status line's counts for one listener; None for a line without it (not armed)."""
+ return (status.get('by_listener') or {}).get(port)
+
+
def evaluate(step, applied, polls, docs, prereq, prior, published):
"""(reasons, summary): the whole verdict, from the apply, every poll and the probe
records, for a record written at `published`."""
@@ -1211,23 +1374,34 @@ def evaluate(step, applied, polls, docs, prereq, prior, published):
probe_reasons, probes, window = probe_findings(docs, applied, step, prereq['public_addresses'])
reasons.extend(probe_reasons)
health = [p for p in polls if p['kind'] == 'health']
- trust = [p for p in polls if p['kind'] == 'trust']
+ trust = sorted((p for p in polls if p['kind'] == 'trust'), key=lambda p: p['at'])
states = [p for p in polls if p['kind'] == 'state']
- for poll in health:
- if 'health' in poll:
- reasons.extend(f"health poll at {poll['at']}: {r}" for r in registered_refusals(poll['health'], targets))
- health_times = [epoch(p['at']) for p in health if 'health' in p]
- reasons.extend(coverage_reasons(health_times, window, HEALTH_GAP_MAX, 'target health'))
- # And all along, from the apply (or reverify) to this record (spec 6.4:
- # every target healthy from the start of the step until its record is written).
- anchor = epoch(record_anchor(applied))
- if anchor is not None:
- reasons.extend(continuous_reasons(health_times, anchor, published, HEALTH_GAP_MAX, 'target health',
- anchor_kind(applied)))
+ # Both target groups, every target healthy at every poll and observed all
+ # along, from the start of the step (the intent's started_at, before tofu
+ # apply; or the reverify) until this record (spec 6.4).
+ start = epoch(applied.get('health_from') or record_anchor(applied))
+ groups = applied.get('tg_arns') or {}
+ for port in LISTENERS:
+ mine = [p for p in health if p.get('port') == port and p.get('tg_arn') == groups.get(port)]
+ for poll in mine:
+ if 'health' in poll:
+ reasons.extend(f"health poll of the :{port} target group at {poll['at']}: {r}"
+ for r in registered_refusals(poll['health'], targets))
+ times = [epoch(p['at']) for p in mine if 'health' in p]
+ what = f'target health in the :{port} target group'
+ reasons.extend(coverage_reasons(times, window, HEALTH_GAP_MAX, what))
+ if start is not None:
+ reasons.extend(continuous_reasons(times, start, published, HEALTH_GAP_MAX, what, anchor_kind(applied)))
+ # Every poll against the baseline and against the target's previous poll:
+ # an edge restart (another edge_instance, or a count that fell) fails the step.
+ prev = {}
for poll in trust:
for iid in targets:
- for r in trust_findings(poll['status'].get(iid, ''), baseline.get(iid), iid, step):
+ status = poll['status'].get(iid, '')
+ for r in trust_findings(status, baseline.get(iid), prev.get(iid), iid, step):
reasons.append(f"trust poll at {poll['at']}: {r}")
+ if is_status(status):
+ prev[iid] = (poll['at'], status)
complete = [p for p in trust if all(is_status(p['status'].get(i)) for i in targets)]
trust_times = [epoch(p['at']) for p in complete]
if all(is_status(baseline.get(i)) for i in targets) and applied.get('baseline_at'):
@@ -1239,14 +1413,21 @@ def evaluate(step, applied, polls, docs, prereq, prior, published):
else:
reasons.extend(f'final trust poll: {s}' for s in final['status'].values() if isinstance(s, str))
if step.startswith('B') and final is not None:
+ # The changed port's own listener: after B80, :80 traffic must not
+ # stand in for a B443 that has not converged.
+ port = STEPS[step].port
for iid in targets:
status, base = final['status'].get(iid), baseline.get(iid)
if not is_status(status) or not is_status(base):
continue
+ if not listener_of(base, port) or not listener_of(status, port):
+ reasons.append(f'{iid}: no :{port} listener counts to converge on')
+ continue
+ was_by, now_by = listener_of(base, port)['proxied_by_node'], listener_of(status, port)['proxied_by_node']
for node in prereq['sources']:
- was, now = base['proxied_by_node'].get(node, 0), status['proxied_by_node'].get(node, 0)
+ was, now = was_by.get(node, 0), now_by.get(node, 0)
if now <= was:
- reasons.append(f'{iid}: proxied from node {node} did not rise ({was} to {now})')
+ reasons.append(f'{iid}: proxied on :{port} from node {node} did not rise ({was} to {now})')
last_state = max(states, key=lambda p: p['at']) if states else None
if last_state is None or 'state' not in last_state:
reasons.append(f"the target group's state was not read: {(last_state or {}).get('error')}")
@@ -1257,6 +1438,7 @@ def evaluate(step, applied, polls, docs, prereq, prior, published):
# incident procedure first. Earlier runs' signals carry forward.
s3_signal = any(re.search(r': (marker_trusted|no_client_refused) moved ', r) for r in unique)
summary = {'s3_signal': s3_signal, 'probes': probes, 'health_polls': len(health), 'trust_polls': len(trust),
+ 'health_from': applied.get('health_from') or record_anchor(applied),
'window': [iso(window[0]), iso(window[1])] if window else None,
'clock_tolerance_s': CLOCK_TOLERANCE,
'clock_tolerance': 'span checks only: probe-host times against this host\'s polls; '
@@ -1268,6 +1450,7 @@ def cmd_converge(args, cloud):
record_dir = Path(args.record_dir)
paths = split(args.probe_records)
targets = target_list(args.targets)
+ groups = groups_of(args)
with locked(record_dir):
# The latest of the step's apply and reverify: that is what a resume continues.
candidates = [r for r in (load_record(record_dir / f'{args.step}-applied.json'),
@@ -1275,8 +1458,8 @@ def cmd_converge(args, cloud):
applied = max(candidates, key=lambda r: epoch(record_anchor(r)) or 0) if candidates else None
if applied is None:
raise Refused(f'no {args.step}-applied.json or {args.step}-verified.json in {record_dir}; run apply first')
- if applied.get('step') != args.step or applied.get('tg_arn') != args.tg_arn:
- raise Refused(f'{args.step}-applied.json is for {applied.get("step")} on {applied.get("tg_arn")}')
+ if applied.get('step') != args.step or applied.get('tg_arns') != groups:
+ raise Refused(f'{args.step}-applied.json is for {applied.get("step")} on {applied.get("tg_arns")}')
if sorted(targets) != sorted(applied.get('targets') or []):
raise Refused(f"--targets must be the apply's targets ({', '.join(applied.get('targets') or [])}); "
'a target cannot leave a step before it converges')
@@ -1328,6 +1511,14 @@ def cmd_prereq(args, cloud):
reasons.append(f'{iid}: no armed line in the carlos-edge journal')
elif sorted(match.group(1).split(',')) != private:
reasons.append(f"{iid} trusts {match.group(1)}, not the NLB's node addresses {','.join(private)}")
+ # The installed guard binary: guard-arm copies it, app updates do not
+ # refresh it, and an old one's guard-exec recover has no PPv2 gate.
+ guards = {}
+ for iid, (code, stdout, stderr) in cloud.ssm(targets, GUARD_CHECK).items():
+ guards[iid] = one_line(stdout or stderr)[:300]
+ reason = guard_refusal(iid, code, stdout, stderr)
+ if reason:
+ reasons.append(reason)
alarms = cloud.aws('cloudwatch', 'describe-alarms', '--alarm-names', args.alarm).get('MetricAlarms') or []
alarm = [a for a in alarms if a.get('AlarmName') == args.alarm]
if not alarm:
@@ -1340,7 +1531,7 @@ def cmd_prereq(args, cloud):
'interfaces': [{'private': p, 'public': a} for p, a in nodes], 'targets': targets,
'target_groups': groups, 'alarm': args.alarm, 'checked_at': iso(cloud.clock.time()), 'passed': passed,
'automated_checks_only': True, 'manual_prerequisites_owed': list(MANUAL_PREREQUISITES),
- 'reasons': reasons, 'trust_status': status, 'armed_lines': lines})
+ 'reasons': reasons, 'trust_status': status, 'armed_lines': lines, 'guard_binaries': guards})
owed = '; '.join(MANUAL_PREREQUISITES)
if passed:
print(f'automated prerequisite checks passed (automated checks only); prereq.json written. '
@@ -1352,14 +1543,77 @@ def cmd_prereq(args, cloud):
return 1
+def guard_refusal(iid, code, stdout, stderr):
+ """Why the installed guard binary on iid would let a pre-vN predecessor
+ run (it does not report ingress-proxy-v2), or None (absent, or it does)."""
+ text = (stdout or '').strip()
+ if code == 0 and text == GUARD_ABSENT:
+ return None
+ if code == 0:
+ doc = first_json(text, 'features')
+ if doc and isinstance(doc.get('features'), list) and FEATURE in doc['features']:
+ return None
+ said = one_line(text or stderr)[:200] or f'exit {code}'
+ return (f'{iid}: the installed guard binary {GUARD_BINARY} does not report {FEATURE} ({said}); '
+ 'app updates do not refresh it, so its guard-exec recover has no PPv2 gate. Bring it to vN or later '
+ 'on this box before the key is published')
+
+
+def cmd_sync_tfvars(args, cloud):
+ """Rewrite ppv2.auto.tfvars.json to both target groups' live attributes,
+ after a direct change outside this tool (the S3 incident procedure's
+ preservation-on command). Never writes S3."""
+ record_dir, root = Path(args.record_dir), Path(args.root)
+ for d, flag in ((record_dir, '--record-dir'), (root, '--root')):
+ if not d.is_dir():
+ raise Refused(f'{flag} {d} is not a directory')
+ groups = groups_of(args)
+ with locked(root, record_dir):
+ check_groups(cloud, groups, args.nlb_arn)
+ live, states = {}, {}
+ for port in LISTENERS:
+ live[port] = cloud.attributes(groups[port])
+ states[port] = state_of(live[port]['preserve_client_ip'], live[port]['proxy_protocol_v2'])
+ if states[port] == 'S3':
+ raise Refused(f'the :{port} target group is in S3 (forbidden); {TFVARS_FILE} is never written with '
+ 'S3. Run the S3 incident procedure (spec 6.5) first')
+ tfvars = root / TFVARS_FILE
+ try:
+ original = tfvars.read_bytes()
+ doc = json.loads(original)
+ except (OSError, ValueError) as err:
+ raise Refused(f'cannot read {tfvars}: {err}')
+ reason = tfvars_shape(doc)
+ if reason:
+ raise Refused(reason + '; fix its shape by hand')
+ new = {key: {port: live[port][attribute] for port in LISTENERS} for attribute, key in TFVARS_KEY.items()}
+ for port in LISTENERS:
+ if state_of(new[TFVARS_KEY['preserve_client_ip']][port], new[TFVARS_KEY['proxy_protocol_v2']][port]) == 'S3':
+ raise Refused(f'{TFVARS_FILE} would describe S3 on :{port}; not written')
+ changes = [f'{key}["{port}"] {norm(doc[key][port])} to {norm(new[key][port])}'
+ for key in sorted(new) for port in LISTENERS if doc[key][port] != new[key][port]]
+ if not changes:
+ print(f'{TFVARS_FILE} already matches the live target groups (:80 {states["80"]}, :443 {states["443"]}); '
+ 'nothing written')
+ return 0
+ edited = (json.dumps(new, indent=2) + '\n').encode()
+ synced_at = iso(cloud.clock.time())
+ write_record(record_dir / f"sync-tfvars-{re.sub(r'[^0-9]', '', synced_at)}.json", {
+ 'nlb_arn': args.nlb_arn, 'tg_arns': groups, 'synced_at': synced_at, 'live': states, 'changes': changes,
+ 'tfvars_before': original.decode(), 'tfvars_after': edited.decode()})
+ atomic_write(tfvars, edited)
+ print(f'{TFVARS_FILE} now matches the live target groups (:80 {states["80"]}, :443 {states["443"]}): '
+ + '; '.join(changes))
+ return 0
+
+
def parser():
p = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
sub = p.add_subparsers(dest='command', required=True)
a = sub.add_parser('apply', help='make one step on one target group, then converge')
a.add_argument('--root', required=True, help='the tofu root directory holding ppv2.auto.tfvars.json')
a.add_argument('--nlb-arn', required=True)
- a.add_argument('--tg-arn', required=True)
- a.add_argument('--tg-address', required=True, help='the target group\'s tofu address')
+ a.add_argument('--tg-address', required=True, help='the stepped target group\'s tofu address')
a.add_argument('--port', required=True, choices=['80', '443'])
a.add_argument('--step', required=True, choices=list(STEPS))
a.add_argument('--record-dir', required=True)
@@ -1369,12 +1623,10 @@ def parser():
c.add_argument('--step', required=True, choices=list(STEPS))
c.add_argument('--record-dir', required=True)
c.add_argument('--probe-records', required=True, help='one probe record path per NLB address, comma-separated')
- c.add_argument('--tg-arn', required=True)
v = sub.add_parser('reverify', help='a fresh convergence window for a step already made')
v.add_argument('--root', required=True, help='the tofu root directory holding ppv2.auto.tfvars.json')
v.add_argument('--nlb-arn', required=True)
- v.add_argument('--tg-arn', required=True)
- v.add_argument('--tg-address', required=True, help='the target group\'s tofu address')
+ v.add_argument('--tg-address', required=True, help='the stepped target group\'s tofu address')
v.add_argument('--port', required=True, choices=['80', '443'])
v.add_argument('--step', required=True, choices=list(STEPS))
v.add_argument('--record-dir', required=True)
@@ -1383,6 +1635,16 @@ def parser():
help='the S3 incident procedure has been run for an S3 signal this step recorded')
for s in (a, c, v):
s.add_argument('--timeout', type=float, default=1800.0, help='seconds to wait for the probe records')
+ s.add_argument('--tg-arn-80', required=True, help='the :80 target group (watched in every step)')
+ s.add_argument('--tg-arn-443', required=True, help='the :443 target group (watched in every step)')
+ y = sub.add_parser('sync-tfvars', help='rewrite ppv2.auto.tfvars.json to the live attributes (after an incident)')
+ y.add_argument('--root', required=True, help='the tofu root directory holding ppv2.auto.tfvars.json')
+ y.add_argument('--nlb-arn', required=True)
+ y.add_argument('--tg-arn-80', required=True)
+ y.add_argument('--tg-arn-443', required=True)
+ y.add_argument('--record-dir', required=True)
+ y.add_argument('--profile', required=True)
+ y.add_argument('--region', required=True)
r = sub.add_parser('prereq', help='the automated prerequisite checks; writes prereq.json')
r.add_argument('--nlb-arn', required=True)
r.add_argument('--tg-arn-80', required=True)
@@ -1409,6 +1671,8 @@ def main(argv=None):
return cmd_converge(args, cloud)
if args.command == 'reverify':
return cmd_reverify(args, cloud)
+ if args.command == 'sync-tfvars':
+ return cmd_sync_tfvars(args, cloud)
return cmd_prereq(args, cloud)
except Refused as err:
print(f'refused: {one_line(err)}', file=sys.stderr)
diff --git a/scripts/ppv2_step_test.py b/scripts/ppv2_step_test.py
index 7c5305323..aaee2062e 100644
--- a/scripts/ppv2_step_test.py
+++ b/scripts/ppv2_step_test.py
@@ -7,6 +7,7 @@ Two harnesses, neither reaching AWS or tofu:
30 s schedules, slow SSM and late probe records are exercised exactly.
Run from the repo root: python3 -m unittest scripts/ppv2_step_test.py
"""
+import argparse
import contextlib
import copy
import fcntl
@@ -98,6 +99,8 @@ def invocation(iid, text):
return [iid, 'Success', 0, json.dumps(sample) + '\n']
if 'journalctl' in text:
return [iid, 'Success', 0, world['journal'][iid] + '\n']
+ if 'system/guard/carlos' in text:
+ return [iid, 'Success', 0, world.get('guard', {}).get(iid, 'ppv2-step: guard binary absent') + '\n']
return [iid, 'Failed', 1, MARK + 'unknown command']
if name == 'aws':
@@ -349,7 +352,7 @@ class Harness(unittest.TestCase):
incident_cleared=False):
port = port or STEP_PLAN.get(step, ('80',))[0]
args = [command, '--root', str(self.root), '--profile', 'kass', '--region', 'eu-west-1',
- '--nlb-arn', nlb, '--tg-arn', TG[port], '--tg-address', ADDR[port],
+ '--nlb-arn', nlb, '--tg-arn-80', TG['80'], '--tg-arn-443', TG['443'], '--tg-address', ADDR[port],
'--port', port, '--step', step, '--targets', ','.join(targets or TARGETS),
'--record-dir', str(self.records), '--timeout', timeout]
if incident_cleared:
@@ -857,7 +860,8 @@ class StepGateTests(Harness):
fcntl.flock(held, fcntl.LOCK_EX | fcntl.LOCK_NB)
result = self.run_step('converge', '--step', 'A80', '--record-dir', str(self.records),
'--probe-records', 'a.json,b.json', '--targets', ','.join(TARGETS),
- '--profile', 'kass', '--region', 'eu-west-1', '--tg-arn', TG['80'])
+ '--profile', 'kass', '--region', 'eu-west-1', '--tg-arn-80', TG['80'],
+ '--tg-arn-443', TG['443'])
self.assert_refused(result, 'another ppv2-step run holds')
# Every run plans into its own file.
names = set()
@@ -882,7 +886,7 @@ class StepGateTests(Harness):
(self.probes / name).write_text(json.dumps(probe_doc(ip, 80, 's1', start, start + 0.2)))
args = ['converge', '--step', 'R80', '--record-dir', str(self.records),
'--probe-records', ','.join(str(self.probes / n) for n in ('a.json', 'b.json')),
- '--profile', 'kass', '--region', 'eu-west-1', '--tg-arn', TG['80']]
+ '--profile', 'kass', '--region', 'eu-west-1', '--tg-arn-80', TG['80'], '--tg-arn-443', TG['443']]
# The targets must be the apply's: a shortened list is refused.
self.assert_refused(self.run_step(*args, '--targets', TARGETS[0]), "must be the apply's targets")
self.run_step(*args, '--targets', ','.join(TARGETS), expect=0)
@@ -1098,7 +1102,7 @@ class ReverifyTests(Harness):
self.ready_for('A80')
self.live({'80': 'S1'})
applied = {'nlb_arn': NLB, 'port': '80', 'step': 'A80', 'applied_at': APPLIED_AT, 'tg_arn': TG['80'],
- 'tg_address': ADDR['80'], 'targets': list(TARGETS),
+ 'tg_arns': dict(TG), 'tg_address': ADDR['80'], 'targets': list(TARGETS),
'baseline': {t: trust('baseline') for t in TARGETS}, 'baseline_at': gate.iso(T0 - 5)}
self.record('A80-applied', **applied)
clock = FakeClock(T0 + 1)
@@ -1166,21 +1170,25 @@ class FakeCloud:
def __init__(self, clock, step):
self.clock = clock
- self.unhealthy = [] # (from s, to s, instance)
+ self.unhealthy = [] # (from s, to s, instance), in both groups
+ self.unhealthy_in = [] # (from s, to s, instance, target group)
self.registered = list(TARGETS)
self.trust_delay = 0.0 # seconds SSM takes to answer
self.samples = {t: [(0, 'b_both_nodes' if step.startswith('B') else 'after_a')] for t in TARGETS}
self.override = {} # instance -> trust-status dict, whatever the time
self.state = STEP_TO[step]
self.health_cost = {} # health call number -> seconds it takes
- self.health_calls, self.jobs = [], {}
+ self.health_calls, self.health_groups, self.jobs = [], [], {}
def health(self, tg):
n = len(self.health_calls)
self.health_calls.append(self.clock.t - T0)
+ self.health_groups.append(tg)
self.clock.t += self.health_cost.get(n, 0)
rel = self.clock.t - T0
- return {iid: 'unhealthy' if any(lo <= rel < hi and who == iid for lo, hi, who in self.unhealthy) else 'healthy'
+ spells = [(lo, hi, who) for lo, hi, who in self.unhealthy]
+ spells += [(lo, hi, who) for lo, hi, who, group in self.unhealthy_in if group == tg]
+ return {iid: 'unhealthy' if any(lo <= rel < hi and who == iid for lo, hi, who in spells) else 'healthy'
for iid in self.registered}
def send(self, targets, command):
@@ -1222,7 +1230,7 @@ class ConvergeTests(unittest.TestCase):
port = STEP_PLAN[step][0]
baseline = 'before_b' if step.startswith('B') else 'baseline'
self.applied = {'nlb_arn': NLB, 'port': port, 'step': step, 'applied_at': APPLIED_AT, 'tg_arn': TG[port],
- 'targets': list(TARGETS), 'baseline': {t: trust(baseline) for t in TARGETS},
+ 'tg_arns': dict(TG), 'targets': list(TARGETS), 'baseline': {t: trust(baseline) for t in TARGETS},
'baseline_at': gate.iso(T0 - 5)}
self.clock = FakeClock(T0 + 1)
self.cloud = FakeCloud(self.clock, step)
@@ -1302,7 +1310,10 @@ class ConvergeTests(unittest.TestCase):
# Counters that may move (proxied, no_client, ignored) do not fail it,
# and a barrier does not fail an A step.
self.fresh('A443')
- self.cloud.samples[TARGETS[1]] = [(0, 'after_a'), (20, 'barrier_up')]
+ up = trust('after_a')
+ up['barrier'] = True
+ self.cloud.samples[TARGETS[1]] = [(0, 'after_a')]
+ self.clock.at(T0 + 20, lambda: self.cloud.override.update({TARGETS[1]: up}))
self.probes()
self.assertEqual(0, self.run_converge()[0])
# A barrier fails a B step's convergence.
@@ -1350,7 +1361,7 @@ class ConvergeTests(unittest.TestCase):
self.probes(at=T0 + 100, finished=T0 + 95)
code, record = self.run_converge()
self.assertEqual(1, code)
- self.assert_reason(record, 'target health was not observed for')
+ self.assert_reason(record, 'target health in the :80 target group was not observed for')
def test_b_convergence_needs_both_nodes(self):
self.fresh('B80')
@@ -1358,7 +1369,7 @@ class ConvergeTests(unittest.TestCase):
self.probes()
code, record = self.run_converge()
self.assertEqual(1, code)
- self.assert_reason(record, TARGETS[1] + ': proxied from node 172.31.11.189 did not rise')
+ self.assert_reason(record, TARGETS[1] + ': proxied on :80 from node 172.31.11.189 did not rise')
self.assertFalse(any(TARGETS[0] in r for r in record['reasons']), record['reasons'])
# Both nodes on every target: passed.
self.fresh('B80')
@@ -1388,7 +1399,8 @@ class ConvergeTests(unittest.TestCase):
self.probes(at=None)
code, record = self.run_converge()
self.assertEqual(1, code)
- self.assert_reason(record, 'target health was not observed before the earliest probe started')
+ self.assert_reason(record, 'target health in the :80 target group was not observed before the earliest probe started',
+ 'target health in the :443 target group was not observed before the earliest probe started')
def test_health_polled_through_final_trust_wait(self):
# The probes finish at 65 s; the final trust poll then takes 40 s. A
@@ -1409,7 +1421,8 @@ class ConvergeTests(unittest.TestCase):
self.probes(at=T0 + 90, started=T0 + 25, finished=T0 + 85)
code, record = self.run_converge()
self.assertEqual(1, code)
- self.assert_reason(record, 'target health was not observed for 20 s after the apply')
+ self.assert_reason(record, 'target health in the :80 target group was not observed for 20 s after the apply',
+ 'target health in the :443 target group was not observed for 20 s after the apply')
# Health answers stop after 72 s and the final trust poll takes 40 s:
# the record is written with the last 40 s unobserved.
self.fresh()
@@ -1521,6 +1534,278 @@ class ConvergeTests(unittest.TestCase):
self.assert_reason(record, 'recorded baselines for')
+class FakeApplyCloud(FakeCloud):
+ """FakeCloud with the calls apply makes before converging: the state and
+ plan reads, per-group attributes, the baseline, and a tofu apply that
+ takes apply_seconds of fake time, calling its tick each second."""
+
+ def __init__(self, clock, step, apply_seconds=60):
+ super().__init__(clock, step)
+ self.step, self.apply_seconds = step, apply_seconds
+ port = STEP_PLAN[step][0]
+ other = '443' if port == '80' else '80'
+ self.states = {TG[port]: STEP_FROM[step], TG[other]: 'S1' if step.startswith('B') else 'S0'}
+ self.tofu_calls, self.applying = [], None
+
+ def attributes(self, tg):
+ preserve, ppv2 = STATES[self.states[tg]]
+ return {'preserve_client_ip': preserve == 'true', 'proxy_protocol_v2': ppv2 == 'true'}
+
+ def target_group(self, tg, nlb, port):
+ if tg != TG[port] or nlb != NLB:
+ raise gate.Refused(f'target group {tg} is not attached to {nlb} on {port}')
+
+ def trust(self, targets):
+ cid = self.send(targets, gate.TRUST_STATUS)
+ return {iid: gate.trust_of(iid, code, out, err) for iid, (_, code, out, err) in self.invocations(cid).items()}
+
+ def tofu(self, root, *args, tick=None):
+ self.tofu_calls.append(args[0])
+ port = STEP_PLAN[self.step][0]
+ done = lambda out='': subprocess.CompletedProcess(args, 0, out, '')
+ if args[:2] == ('state', 'show'):
+ return done(state_output(port))
+ if args[0] == 'plan':
+ return done()
+ if args[:2] == ('show', '-json'):
+ return done(json.dumps(plan_for_step(self.step)))
+ if args[0] == 'apply':
+ self.applying = (self.clock.t, None)
+ for _ in range(int(self.apply_seconds)):
+ if tick:
+ tick()
+ self.clock.sleep(1)
+ self.states[TG[port]] = STEP_TO[self.step]
+ self.state = STEP_TO[self.step]
+ self.applying = (self.applying[0], self.clock.t)
+ return done()
+ raise AssertionError(args)
+
+
+class BothGroupsHealthTests(unittest.TestCase):
+ """W9: health in BOTH target groups, from before tofu apply to the verdict."""
+
+ def setUp(self):
+ self.tmp = tempfile.TemporaryDirectory(dir=os.environ.get('TMPDIR'))
+ self.addCleanup(self.tmp.cleanup)
+ base = Path(self.tmp.name)
+ self.root, self.records = base / 'root', base / 'records'
+ self.root.mkdir()
+ self.records.mkdir()
+ write_prereq(self.records)
+ self.paths = [str(base / 'a.json'), str(base / 'b.json')]
+
+ def run_apply(self, cloud, step='A80'):
+ port = STEP_PLAN[step][0]
+ (self.root / 'ppv2.auto.tfvars.json').write_bytes(tfvars_for({TG_PORT[t]: st for t, st in cloud.states.items()}))
+ args = argparse.Namespace(root=str(self.root), nlb_arn=NLB, tg_arn_80=TG['80'], tg_arn_443=TG['443'],
+ tg_address=ADDR[port], port=port, step=step, record_dir=str(self.records),
+ probe_records=','.join(self.paths), targets=','.join(TARGETS), timeout=600.0)
+ with contextlib.redirect_stdout(io.StringIO()), contextlib.redirect_stderr(io.StringIO()):
+ code = gate.cmd_apply(args, cloud)
+ return code, json.loads((self.records / f'{step}.json').read_text())
+
+ def probes_after(self, clock, start, step='A80'):
+ port = STEP_PLAN[step][0]
+
+ def write():
+ for path, ip in zip(self.paths, PUBLIC):
+ Path(path).write_text(json.dumps(probe_doc(ip, port, EXPECT[step[0]], start, start + 60)))
+ clock.at(start + 65, write)
+
+ def cloud(self):
+ clock = FakeClock(T0 + 1)
+ cloud = FakeApplyCloud(clock, 'A80', apply_seconds=60)
+ cloud.samples = {t: [(-100, 'baseline'), (5, 'after_a')] for t in TARGETS}
+ self.probes_after(clock, T0 + 70)
+ return clock, cloud
+
+ def test_health_watched_through_tofu_apply_in_both_groups(self):
+ clock, cloud = self.cloud()
+ code, record = self.run_apply(cloud)
+ self.assertEqual(0, code, record['reasons'])
+ intent = json.loads((self.records / 'A80-intent.json').read_text())
+ applied = json.loads((self.records / 'A80-applied.json').read_text())
+ self.assertEqual(intent['started_at'], applied['health_from'])
+ self.assertEqual(intent['started_at'], applied['polls_anchor'])
+ self.assertEqual(dict(TG), applied['tg_arns'])
+ start, end = cloud.applying
+ for tg in TG.values():
+ during = [t + T0 for t, g in zip(cloud.health_calls, cloud.health_groups) if g == tg and start - 1 <= t + T0 <= end]
+ self.assertGreaterEqual(len(during), 6, (tg, during))
+ gaps = [b - a for a, b in zip(during, during[1:])]
+ self.assertTrue(all(g <= gate.HEALTH_GAP_MAX for g in gaps), gaps)
+ # The first poll is before tofu apply starts.
+ self.assertLessEqual(during[0], start)
+
+ def test_unhealthy_during_apply_in_the_other_group_fails(self):
+ clock, cloud = self.cloud()
+ # A443's group is not the one A80 changes; a target there goes
+ # unhealthy while tofu apply runs, and is healthy again before the
+ # apply returns.
+ cloud.unhealthy_in.append((15, 35, TARGETS[1], TG['443']))
+ code, record = self.run_apply(cloud)
+ self.assertEqual(1, code)
+ self.assertTrue(any(r.startswith('health poll of the :443 target group at ') and TARGETS[1] + ' is unhealthy' in r
+ for r in record['reasons']), record['reasons'])
+
+ def test_unhealthy_during_apply_in_the_stepped_group_fails(self):
+ clock, cloud = self.cloud()
+ cloud.unhealthy_in.append((15, 35, TARGETS[0], TG['80']))
+ code, record = self.run_apply(cloud)
+ self.assertEqual(1, code)
+ self.assertTrue(any(r.startswith('health poll of the :80 target group at ') and TARGETS[0] + ' is unhealthy' in r
+ for r in record['reasons']), record['reasons'])
+
+ def test_unhealthy_in_the_other_group_during_convergence_fails(self):
+ clock, cloud = self.cloud()
+ cloud.unhealthy_in.append((90, 110, TARGETS[1], TG['443']))
+ code, record = self.run_apply(cloud)
+ self.assertEqual(1, code)
+ self.assertTrue(any(':443 target group' in r and TARGETS[1] + ' is unhealthy' in r for r in record['reasons']),
+ record['reasons'])
+
+ def test_other_group_unobserved_fails(self):
+ clock, cloud = self.cloud()
+ answer = cloud.health
+ calls = {'n': 0}
+
+ def no_443_after_the_check(tg):
+ # The pre-apply check reads both groups; after it, :443 never answers.
+ calls['n'] += 1
+ if tg == TG['443'] and calls['n'] > 2:
+ raise gate.Refused('aws elbv2 describe-target-health failed: AccessDenied')
+ return answer(tg)
+ cloud.health = no_443_after_the_check
+ code, record = self.run_apply(cloud)
+ self.assertEqual(1, code)
+ self.assertTrue(any('target health in the :443 target group was not observed' in r for r in record['reasons']),
+ record['reasons'])
+
+
+TG_PORT = {arn: port for port, arn in TG.items()}
+
+
+class ListenerAndRestartTests(ConvergeTests):
+ """W10: B steps converge on the changed port's listener; W11: an edge
+ restart (another instance, or a count that fell since the last poll)
+ fails the window."""
+
+ def test_b443_needs_its_own_listener_traffic(self):
+ # After B80, :80 traffic is proxied from both nodes; :443 has not moved.
+ self.fresh('B443')
+ self.cloud.samples = {t: [(0, 'b_port80_only')] for t in TARGETS}
+ self.probes()
+ code, record = self.run_converge()
+ self.assertEqual(1, code)
+ for iid in TARGETS:
+ self.assert_reason(record, f'{iid}: proxied on :443 from node 172.31.11.189 did not rise',
+ f'{iid}: proxied on :443 from node 172.31.29.110 did not rise')
+ # The same counts are B80's evidence: :80 rose on both nodes.
+ self.fresh('B80')
+ self.cloud.samples = {t: [(0, 'b_port80_only')] for t in TARGETS}
+ self.probes()
+ code, record = self.run_converge()
+ self.assertEqual(0, code, record['reasons'])
+
+ def test_restart_with_higher_counts_fails(self):
+ # A new edge whose counts already exceed the baseline: only its
+ # instance tells.
+ self.fresh('A80')
+ self.cloud.samples[TARGETS[1]] = [(0, 'after_a'), (20, 'restarted_counts_higher')]
+ self.probes()
+ code, record = self.run_converge()
+ self.assertEqual(1, code)
+ self.assert_reason(record, TARGETS[1] + ': edge_instance changed from ', 'the edge restarted during the step')
+
+ def test_count_falling_between_polls_fails(self):
+ # 5120 at the baseline, 5180 at one poll, 5150 at the next: above the
+ # baseline all along, but it fell.
+ self.fresh('A80')
+ self.cloud.samples[TARGETS[1]] = [(0, 'after_a'), (20, 'fell_since_last_poll')]
+ self.probes()
+ code, record = self.run_converge()
+ self.assertEqual(1, code)
+ self.assert_reason(record, TARGETS[1] + ': no_client fell from 5180 to 5150 since the poll at ',
+ TARGETS[1] + ': no_client on :443 fell from 2590 to 2560 since the poll at ')
+
+ def test_status_line_shape(self):
+ good = trust('after_a')
+ self.assertIsNotNone(gate.parse_trust(json.dumps(good)))
+ broken = []
+ for mutate in (lambda d: d.pop('edge_instance'), lambda d: d.update(edge_instance=''),
+ lambda d: d.pop('by_listener'), lambda d: d['by_listener'].pop('443'),
+ lambda d: d['by_listener'].update({'8080': d['by_listener']['80']}),
+ lambda d: d['by_listener']['80'].pop('timeout'),
+ lambda d: d['by_listener']['80'].pop('proxied_by_node'),
+ lambda d: d['by_listener']['80'].update(no_client=d['by_listener']['80']['no_client'] + 1),
+ lambda d: d['by_listener']['443']['proxied_by_node'].update({'172.31.11.189': 1})):
+ d = copy.deepcopy(good)
+ mutate(d)
+ broken.append(gate.parse_trust(json.dumps(d)))
+ self.assertEqual([None] * len(broken), broken)
+ unarmed = {'armed': False, 'barrier': False, 'edge_instance': '', 'counters': dict.fromkeys(gate.COUNTERS, 0),
+ 'proxied_by_node': {}, 'by_listener': {}}
+ self.assertIsNotNone(gate.parse_trust(json.dumps(unarmed)))
+
+
+class SyncTfvarsTests(Harness):
+ """W13: after the incident's direct preservation-on command, sync-tfvars
+ puts the file back in line with live, under the lock; never S3."""
+
+ def sync(self, expect=None):
+ return self.run_step('sync-tfvars', '--root', str(self.root), '--nlb-arn', NLB, '--tg-arn-80', TG['80'],
+ '--tg-arn-443', TG['443'], '--record-dir', str(self.records), '--profile', 'kass',
+ '--region', 'eu-west-1', expect=expect)
+
+ def test_sync_after_direct_preservation_on(self):
+ # :443 was in S2 (B443 made) and went to S3; the incident procedure
+ # turned preservation back on directly, so live :443 is S0 while the
+ # file still says S2, and A443 (the way back) refuses on the file.
+ self.ready_for('A443')
+ self.live({'80': 'S2', '443': 'S0'}, tfvars=False)
+ self.tfvars.write_bytes(tfvars_for({'80': 'S2', '443': 'S2'}))
+ before = self.tfvars.read_bytes()
+ self.assert_refused(self.apply('A443'), 'disagrees with the live')
+ self.assertEqual(before, self.tfvars.read_bytes())
+ result = self.sync(expect=0)
+ self.assertIn('ppv2_preserve_client_ip["443"] false to true', result.stdout)
+ self.assertIn('ppv2_proxy_protocol_v2["443"] true to false', result.stdout)
+ self.assertEqual(json.loads(tfvars_for({'80': 'S2', '443': 'S0'})), json.loads(self.tfvars.read_text()))
+ live443 = {'preserve_client_ip': True, 'proxy_protocol_v2': False}
+ self.assertIsNone(gate.tfvars_check(json.loads(self.tfvars.read_text()), '443', live443))
+ records = list(self.records.glob('sync-tfvars-*.json'))
+ self.assertEqual(1, len(records))
+ self.assertEqual(before.decode(), json.loads(records[0].read_text())['tfvars_before'])
+ # Nothing to do the second time.
+ self.assertIn('already matches', self.sync(expect=0).stdout)
+ self.assertEqual(1, len(list(self.records.glob('sync-tfvars-*.json'))))
+ self.assertNotIn('plan', self.tofu_ops())
+
+ def test_sync_refuses_s3(self):
+ self.live({'80': 'S3', '443': 'S1'}, tfvars=False)
+ self.tfvars.write_bytes(tfvars_for({'80': 'S2', '443': 'S1'}))
+ before = self.tfvars.read_bytes()
+ self.assert_refused(self.sync(), 'is in S3')
+ self.assertEqual(before, self.tfvars.read_bytes())
+ self.assertEqual([], list(self.records.glob('sync-tfvars-*.json')))
+
+ def test_sync_holds_the_lock_and_checks_groups(self):
+ self.live({'80': 'S1', '443': 'S0'}, tfvars=False)
+ self.tfvars.write_bytes(tfvars_for({'80': 'S0', '443': 'S0'}))
+ before = self.tfvars.read_bytes()
+ with open(self.root / '.ppv2-step.lock', 'a') as held:
+ fcntl.flock(held, fcntl.LOCK_EX | fcntl.LOCK_NB)
+ self.assert_refused(self.sync(), 'another ppv2-step run holds')
+ self.assertEqual(before, self.tfvars.read_bytes())
+ self.world['target_groups'][TG['443']]['LoadBalancerArns'] = [OTHER_NLB]
+ self.assert_refused(self.sync(), 'not attached to')
+ self.assertEqual(before, self.tfvars.read_bytes())
+ self.tfvars.write_text('{"ppv2_preserve_client_ip": {"80": true}}')
+ self.world['target_groups'][TG['443']]['LoadBalancerArns'] = [NLB]
+ self.assert_refused(self.sync(), 'fix its shape by hand')
+
+
class PrereqTests(Harness):
def run_prereq(self, expect=None, sources=SOURCES):
return self.run_step('prereq', '--profile', 'kass', '--region', 'eu-west-1', '--nlb-arn', NLB,
@@ -1537,6 +1822,15 @@ class PrereqTests(Harness):
self.assertTrue(record['automated_checks_only'])
self.assertEqual(4, len(record['manual_prerequisites_owed']))
self.assertEqual((NLB, SOURCES, PUBLIC), (record['nlb_arn'], record['sources'], record['public_addresses']))
+ self.assertEqual({t: 'ppv2-step: guard binary absent' for t in TARGETS}, record['guard_binaries'])
+ guard_checks = [c for c in self.calls() if c.get('op') == 'ssm send-command'
+ and 'system/guard/carlos' in json.dumps(c['args'])]
+ self.assertEqual(1, len(guard_checks))
+ self.assertEqual(sorted(TARGETS), sorted(guard_checks[0]['instances']))
+ # A guard binary that reports the feature passes.
+ self.setUp()
+ self.world['guard'] = {t: '{"version":"v0.35.0","features":["ingress-proxy-v2"]}' for t in TARGETS}
+ self.run_prereq(expect=0)
cases = {
'TG not in S0': (lambda: self.live({'80': 'S1', '443': 'S0'}), 'S1'),
'other addresses': (lambda: self.world['journal'].update(
@@ -1554,6 +1848,11 @@ class PrereqTests(Harness):
"are not the NLB's node addresses"),
'no public address': (lambda: self.world['interfaces'][1].pop('public'), 'no public address'),
'no interfaces': (lambda: self.world.update(nlb_suffix='net/other/1'), 'no network interfaces'),
+ # W12: an installed guard binary older than the PPv2 gate.
+ 'old guard binary': (lambda: self.world.update(guard={TARGETS[1]: 'carlos v0.34.49'}),
+ TARGETS[1] + ': the installed guard binary /opt/carlos/system/guard/carlos does not report'),
+ 'guard without the feature': (lambda: self.world.update(
+ guard={TARGETS[0]: '{"version":"v0.35.0","features":[]}'}), TARGETS[0] + ': the installed guard binary'),
}
for name, (fault, text) in cases.items():
with self.subTest(case=name):
diff --git a/scripts/testdata/ppv2/trust-status.json b/scripts/testdata/ppv2/trust-status.json
index 317897236..a25b041bf 100644
--- a/scripts/testdata/ppv2/trust-status.json
+++ b/scripts/testdata/ppv2/trust-status.json
@@ -1,14 +1,17 @@
{
- "_comment": "Recorded `carlos system edge trust-status` lines (one JSON line each on the box), keyed by situation. Shapes follow internal/host/edgetrust.go trustStatus.",
- "baseline": {"armed": true, "barrier": false, "counters": {"proxied": 0, "no_client": 5120, "no_client_refused": 0, "ignored": 0, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0}, "proxied_by_node": {}},
- "after_a": {"armed": true, "barrier": false, "counters": {"proxied": 0, "no_client": 5180, "no_client_refused": 0, "ignored": 412, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0}, "proxied_by_node": {}},
- "before_b": {"armed": true, "barrier": false, "counters": {"proxied": 0, "no_client": 6010, "no_client_refused": 0, "ignored": 1830, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0}, "proxied_by_node": {}},
- "b_both_nodes": {"armed": true, "barrier": false, "counters": {"proxied": 377, "no_client": 6070, "no_client_refused": 0, "ignored": 1902, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0}, "proxied_by_node": {"172.31.11.189": 181, "172.31.29.110": 196}},
- "b_one_node": {"armed": true, "barrier": false, "counters": {"proxied": 196, "no_client": 6070, "no_client_refused": 0, "ignored": 1902, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0}, "proxied_by_node": {"172.31.29.110": 196}},
- "malformed_moved": {"armed": true, "barrier": false, "counters": {"proxied": 0, "no_client": 5180, "no_client_refused": 0, "ignored": 412, "ignored_private": 0, "marker_trusted": 0, "malformed": 1, "timeout": 0}, "proxied_by_node": {}},
- "marker_trusted_moved": {"armed": true, "barrier": false, "counters": {"proxied": 0, "no_client": 5180, "no_client_refused": 0, "ignored": 412, "ignored_private": 0, "marker_trusted": 2, "malformed": 0, "timeout": 0}, "proxied_by_node": {}},
- "no_client_refused_moved": {"armed": true, "barrier": false, "counters": {"proxied": 0, "no_client": 5180, "no_client_refused": 7, "ignored": 412, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0}, "proxied_by_node": {}},
- "restarted": {"armed": true, "barrier": false, "counters": {"proxied": 0, "no_client": 12, "no_client_refused": 0, "ignored": 3, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0}, "proxied_by_node": {}},
- "barrier_up": {"armed": true, "barrier": true, "counters": {"proxied": 0, "no_client": 5120, "no_client_refused": 0, "ignored": 0, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0}, "proxied_by_node": {}},
+ "_comment": "Recorded `carlos system edge trust-status` lines (one JSON line each on the box), keyed by situation. Shapes follow internal/host/edgetrust.go trustStatus: counters and proxied_by_node sum by_listener (keyed \"80\" and \"443\"); edge_instance is set once per edge start.",
+ "baseline": {"armed": true, "barrier": false, "edge_instance": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "counters": {"proxied": 0, "no_client": 5120, "no_client_refused": 0, "ignored": 0, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0}, "proxied_by_node": {}, "by_listener": {"80": {"proxied": 0, "no_client": 2560, "no_client_refused": 0, "ignored": 0, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}, "443": {"proxied": 0, "no_client": 2560, "no_client_refused": 0, "ignored": 0, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}}},
+ "after_a": {"armed": true, "barrier": false, "edge_instance": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "counters": {"proxied": 0, "no_client": 5180, "no_client_refused": 0, "ignored": 412, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0}, "proxied_by_node": {}, "by_listener": {"80": {"proxied": 0, "no_client": 2590, "no_client_refused": 0, "ignored": 206, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}, "443": {"proxied": 0, "no_client": 2590, "no_client_refused": 0, "ignored": 206, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}}},
+ "before_b": {"armed": true, "barrier": false, "edge_instance": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "counters": {"proxied": 0, "no_client": 6010, "no_client_refused": 0, "ignored": 1830, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0}, "proxied_by_node": {}, "by_listener": {"80": {"proxied": 0, "no_client": 3005, "no_client_refused": 0, "ignored": 915, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}, "443": {"proxied": 0, "no_client": 3005, "no_client_refused": 0, "ignored": 915, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}}},
+ "b_both_nodes": {"armed": true, "barrier": false, "edge_instance": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "counters": {"proxied": 377, "no_client": 6070, "no_client_refused": 0, "ignored": 1902, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0}, "proxied_by_node": {"172.31.11.189": 181, "172.31.29.110": 196}, "by_listener": {"80": {"proxied": 188, "no_client": 3035, "no_client_refused": 0, "ignored": 951, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {"172.31.11.189": 90, "172.31.29.110": 98}}, "443": {"proxied": 189, "no_client": 3035, "no_client_refused": 0, "ignored": 951, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {"172.31.11.189": 91, "172.31.29.110": 98}}}},
+ "b_one_node": {"armed": true, "barrier": false, "edge_instance": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "counters": {"proxied": 196, "no_client": 6070, "no_client_refused": 0, "ignored": 1902, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0}, "proxied_by_node": {"172.31.29.110": 196}, "by_listener": {"80": {"proxied": 98, "no_client": 3035, "no_client_refused": 0, "ignored": 951, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {"172.31.29.110": 98}}, "443": {"proxied": 98, "no_client": 3035, "no_client_refused": 0, "ignored": 951, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {"172.31.29.110": 98}}}},
+ "b_port80_only": {"armed": true, "barrier": false, "edge_instance": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "counters": {"proxied": 377, "no_client": 6070, "no_client_refused": 0, "ignored": 1902, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0}, "proxied_by_node": {"172.31.11.189": 181, "172.31.29.110": 196}, "by_listener": {"80": {"proxied": 377, "no_client": 3065, "no_client_refused": 0, "ignored": 987, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {"172.31.11.189": 181, "172.31.29.110": 196}}, "443": {"proxied": 0, "no_client": 3005, "no_client_refused": 0, "ignored": 915, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}}},
+ "malformed_moved": {"armed": true, "barrier": false, "edge_instance": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "counters": {"proxied": 0, "no_client": 5180, "no_client_refused": 0, "ignored": 412, "ignored_private": 0, "marker_trusted": 0, "malformed": 1, "timeout": 0}, "proxied_by_node": {}, "by_listener": {"80": {"proxied": 0, "no_client": 2590, "no_client_refused": 0, "ignored": 206, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}, "443": {"proxied": 0, "no_client": 2590, "no_client_refused": 0, "ignored": 206, "ignored_private": 0, "marker_trusted": 0, "malformed": 1, "timeout": 0, "proxied_by_node": {}}}},
+ "marker_trusted_moved": {"armed": true, "barrier": false, "edge_instance": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "counters": {"proxied": 0, "no_client": 5180, "no_client_refused": 0, "ignored": 412, "ignored_private": 0, "marker_trusted": 2, "malformed": 0, "timeout": 0}, "proxied_by_node": {}, "by_listener": {"80": {"proxied": 0, "no_client": 2590, "no_client_refused": 0, "ignored": 206, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}, "443": {"proxied": 0, "no_client": 2590, "no_client_refused": 0, "ignored": 206, "ignored_private": 0, "marker_trusted": 2, "malformed": 0, "timeout": 0, "proxied_by_node": {}}}},
+ "no_client_refused_moved": {"armed": true, "barrier": false, "edge_instance": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "counters": {"proxied": 0, "no_client": 5180, "no_client_refused": 7, "ignored": 412, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0}, "proxied_by_node": {}, "by_listener": {"80": {"proxied": 0, "no_client": 2590, "no_client_refused": 0, "ignored": 206, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}, "443": {"proxied": 0, "no_client": 2590, "no_client_refused": 7, "ignored": 206, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}}},
+ "restarted": {"armed": true, "barrier": false, "edge_instance": "b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2", "counters": {"proxied": 0, "no_client": 12, "no_client_refused": 0, "ignored": 3, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0}, "proxied_by_node": {}, "by_listener": {"80": {"proxied": 0, "no_client": 6, "no_client_refused": 0, "ignored": 1, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}, "443": {"proxied": 0, "no_client": 6, "no_client_refused": 0, "ignored": 2, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}}},
+ "restarted_counts_higher": {"armed": true, "barrier": false, "edge_instance": "b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2", "counters": {"proxied": 0, "no_client": 6180, "no_client_refused": 0, "ignored": 1412, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0}, "proxied_by_node": {}, "by_listener": {"80": {"proxied": 0, "no_client": 2590, "no_client_refused": 0, "ignored": 206, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}, "443": {"proxied": 0, "no_client": 3590, "no_client_refused": 0, "ignored": 1206, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}}},
+ "fell_since_last_poll": {"armed": true, "barrier": false, "edge_instance": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "counters": {"proxied": 0, "no_client": 5150, "no_client_refused": 0, "ignored": 412, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0}, "proxied_by_node": {}, "by_listener": {"80": {"proxied": 0, "no_client": 2590, "no_client_refused": 0, "ignored": 206, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}, "443": {"proxied": 0, "no_client": 2560, "no_client_refused": 0, "ignored": 206, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}}},
+ "barrier_up": {"armed": true, "barrier": true, "edge_instance": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "counters": {"proxied": 0, "no_client": 5120, "no_client_refused": 0, "ignored": 0, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0}, "proxied_by_node": {}, "by_listener": {"80": {"proxied": 0, "no_client": 2560, "no_client_refused": 0, "ignored": 0, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}, "443": {"proxied": 0, "no_client": 2560, "no_client_refused": 0, "ignored": 0, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}}},
"not_armed": {"rc": 2, "stderr": "edge: this box is not armed for PROXY protocol\n"}
}