AGENT SKILL

chaos-experiment

Design a chaos experiment — hypothesis, blast radius, abort criteria, observation, rollback; small-radius first.

License 许可
MIT
最近更新
2026-10-29
Stars
★ 0
Forks
0

01 前言 Front Matter

name
chaos-experiment
description
Design a chaos experiment — hypothesis, blast radius, abort criteria, observation, rollback; small-radius first.

03 SKILL.md 正文

chaos-experiment

Design one chaos experiment. Output is the hypothesis + plan + abort criteria + observation.

Mode: analytical — judgment inside a fixed frame. Keep the output shape; every verdict cites its evidence; unknowns are marked [TBD] or [VERIFY], never filled in.

When to use

  • A system is supposed to tolerate a failure that's never been tested.
  • An on-call wants to verify a runbook works before they need it.
  • A workflow needs a resilience signal before a major release.

Inputs

  • The system and the failure it is supposed to tolerate (required).
  • The SLO / steady-state signal that defines "fine" (required) — the abort criteria derive from it. Absent: stop and get it (or run polymath-sre:slo-design); an experiment without a steady state can't be judged.
  • The environment and the operator who will run it (required for anything beyond dev). Prod needs the service owner's sign-off.

Procedure

  1. Hypothesis — a single falsifiable statement: "When pod X dies, request error rate stays under 0.5% for 5 minutes." Not "we want to know what happens".
  2. Blast radius — smallest first. Run in dev → staging → one prod canary → broader prod. Never start in prod. Prod runs need the service owner's sign-off and an announced window. You design the experiment; a human runs it. Never execute the injection yourself unless the operator explicitly tells you to, for that environment, at that moment.
  3. Failure to inject — pick one:
    • Pod kill / node drain.
    • Network latency / partition between two services.
    • Disk full on one node.
    • Dependency 5xx burst (one downstream).
    • Clock skew (small).
  4. Abort criteria — what makes you stop immediately:
    • Customer-facing error rate > X% (above the SLO threshold).
    • On-call alarmed for an unrelated reason.
    • Blast radius leaked (the experiment is affecting more than the target).
  5. Observation — what you watch during the experiment. Pre-built dashboard. Compare against the hypothesis.
  6. Rollback — how the injected failure is removed. Some tools do this automatically; never run an experiment without a rollback plan.
  7. Postmortem — even if the hypothesis holds, capture what you learned. If it didn't hold, this is a fix-now finding.

Output

Chaos experiment: pod kill on refund-service (canary, staging)

Hypothesis:
  When one refund-service pod dies, error rate stays < 0.5% for 5
  minutes and recovery (back to baseline) takes < 30 seconds.

Pre-conditions:
  - SLO healthy on refund-service.
  - 3 replicas running.
  - On-call team aware (scheduled in #payments-eng).

Injection (exactly one pod — `kubectl delete pod -l …` alone would delete
every matching pod):
  pod="$(kubectl get pods -n payments -l app.kubernetes.io/name=refund -o name | shuf -n 1)" \
    && kubectl delete -n payments "$pod"

Observation (5 minutes):
  Grafana dashboard `refund-canary-chaos` showing:
    - request rate
    - 5xx rate (must stay < 0.5%)
    - P99 latency
    - replica count
    - pod restart count

Abort criteria:
  - 5xx rate > 1% sustained 30s.
  - Latency P99 > 2s sustained 60s.
  - Any sev1/sev2 alert fires unrelated to the experiment.

Rollback:
  Replica set controller respawns the pod automatically; no manual action.

Postmortem:
  Did the hypothesis hold? If recovery > 30s, file ticket for readiness probe
  or PDB tuning.

Promotion plan:
  Pass at staging → run on one prod canary pod → pass → run across prod.

Anti-patterns to avoid

  • "Just turn off X and see what happens." No hypothesis, no signal.
  • Starting in prod.
  • No abort criteria.
  • No rollback plan because "it'll recover on its own".
  • An injection command whose selector matches more than the intended target (a label selector without picking one pod).

04 同仓库更多 Skills