Skip to content

Chaos Drills: Scheduled Failover Fire Drills

License: pro tier and above. See Licensing.

A failover you have never exercised is a failover you hope works. A chaos drill exercises it on a schedule: it takes one member of a pool out of rotation, checks that every service on the pool actually steers away from it, puts the member back, and keeps a report.

What a drill really does

This is a real, brief outage of one member, not a simulation. The member is disabled in the shared datastore, so live traffic on every node stops being sent to it for the length of the run (normally a second or less). That is the point: a dry run cannot tell you the failover works. Pick a pool with enough capacity to lose a member, and a time of day you are comfortable with.

Each run:

  1. Guards. The run is skipped, and says why, if any of these hold:
  2. failing a member would leave fewer healthy members than the drill's minHealthy (default 1);
  3. no service routes to the pool, so there would be nothing to verify;
  4. another drill is already in flight on the pool.
  5. Picks a member. Enabled, healthy members are rotated through in a fixed order, so over a few runs every member is exercised.
  6. Fails it by disabling it, and flushes the local DNS answer cache.
  7. Verifies every service on the pool with the query tracer: the failed member must not be in the answer, and the service must still have an answer at all (a service left with no candidate is a failed drill).
  8. Restores the member and records the report.

Restore is guaranteed

The run is written to the database before the member is disabled, with a two-minute restore deadline. The run restores in a defer, so an error or a panic still restores. If the whole daemon dies mid-drill, every node sweeps for runs past their deadline and re-enables the member. Deleting a drill does not strand a member either, because the restore is tracked by the run, not the schedule.

Scheduling

A drill fires on a UTC time of day, on chosen weekdays (or every day). There is no cron syntax: weekdays is a list of 0 (Sunday) to 6 (Saturday) and timeOfDay is HH:MM. Every node checks for due drills, and the firing is claimed with a compare-and-set, so exactly one node runs each occurrence.

Creating and running drills

WebUI: Admin → Chaos Drills. Schedule a drill, use the play button to run one immediately, and expand a row for its reports.

gslbctl:

gslbctl drills schedule --name weekly-web --pool <pool-id> --at 03:00 --days tue --min-healthy 2
gslbctl drills list
gslbctl drills run <drill-id>        # exits 2 if the drill failed or errored
gslbctl drills reports <drill-id> --limit 5
gslbctl drills delete <drill-id>

drills run exits non-zero on failed or error, so it can gate a CI job or a cron wrapper. A skipped run exits 0: the guard did its job.

Terraform: see nexus_drill in the provider. It is fire-and-forget: every input forces replacement, because there is no update API.

REST: GET/POST /api/v1/drills, DELETE /api/v1/drills/{id}, POST /api/v1/drills/{id}/run, GET /api/v1/drills/{id}/runs. Permissions are drill:read and drill:write. See the reference.

Reading a report

Status Meaning
passed Every service steered away from the failed member and still answered.
failed The drill ran, and at least one service still selected the failed member or was left with no answer. The per-service checks say which.
skipped A guard refused to start. Nothing was touched. reason says which guard.
error The drill could not complete (a store or DNS error). The member was restored regardless.

Each report also records whether the member was restored. A member-taking run showing not restored means the sweep has not reached it yet; it will be restored within one 30-second sweep of the run's deadline (two minutes after it started).

Limits worth knowing

  • One vantage point. The trace runs on the node that fired the drill, for a single probe client (192.0.2.1, a documentation address no geo rule should know). It shows the default routing, not what a client in every region would see. A service whose steering depends on client location can pass here and still misroute a specific region.
  • Live query statistics are not asserted. The verdict comes from the tracer, not from watching real query counters shift.
  • Other nodes converge within the cache TTL. The disable is in the shared datastore, but each node's answer cache (database.cacheTTL) can keep serving the member briefly. Only the firing node flushes immediately. A run shorter than the TTL may therefore barely register on other nodes.
  • Failed drills do not alert yet. A failed report is visible in the WebUI, CLI and API, and logged at warn level, but it does not fire a webhook, email or pager notification.
  • Pool-level only. A drill targets a pool and rotates through its members; you cannot pin it to one named member.