Rehearse a fleet rollout and rollback
Operate a deterministic fictional device fleet, evaluate health thresholds, stage firmware through a canary, and preserve the timeline of an automatic rollback.

Cloud Clara: I want you to connect every fleet signal to the gate decision, recovery action, and final reported state.
Predict the reading, then compare it with the measurement.
Python 3 in your browser (JupyterLite)
Python · no installOperate a deterministic fictional device fleet, evaluate health thresholds, stage firmware through a canary, and preserve the timeline of an automatic rollback.
Open the notebook in your browser and run each Python cell; no install or account is needed.
Three ways to run: use JupyterLite here with no install; run main.py locally from the downloadable lab folder; or open the same notebook in Google Colab.
Steps
Step 1
- Do
- Run `python3 main.py --step 1` to create the six-device fleet from seed 731.
- You will see
- A table lists pump-01 through pump-06 with region, reported firmware, battery, temperature, and heartbeat age.
- Why it matters
- A rollout decision needs an explicit reported-state snapshot rather than only a fleet total.

Step 1 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab) Step 2
- Do
- Run `python3 main.py --step 2` to evaluate the fleet's health snapshot against three thresholds.
- You will see
- The rules are printed above six rows: four devices are OK, while pump-04 and pump-06 show ALERT for their measured values.
- Why it matters
- Putting readings beside thresholds makes cohort exclusion and later alerts auditable.

Step 2 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab) Step 3
- Do
- Run `python3 main.py --step 3` to fire alerts and exclude unhealthy devices from the rollout.
- You will see
- Timestamped alert lines name pump-04's temperature breach and pump-06's heartbeat and battery breaches before the operator exclusion event.
- Why it matters
- The individual rule evidence explains why those devices are excluded while still remaining under monitoring.

Step 3 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab) Step 4
- Do
- Run `python3 main.py --step 4` to inspect the rolling firmware plan and safety gate.
- You will see
- The eligible, canary, and next-batch cohorts are named beside the success signal and `pause when cohort error rate > 20%; restore 2.3.1` rule.
- Why it matters
- A staged change is safe only when scope, success evidence, breach threshold, and rollback target are decided before execution.

Step 4 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab) Step 5
- Do
- Run `python3 main.py --step 5` to update and observe the two canary devices.
- You will see
- Commands and acknowledgements for pump-01 and pump-03 report firmware 2.4.0 with no errors; `0.0% <= 20.0% -> PROCEED` opens the next batch.
- Why it matters
- Reported version and error signals prove the canary result before rollout scope widens.

Step 5 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab) Step 6
- Do
- Run `python3 main.py --step 6` to update the next batch and inject pump-05's boot failure.
- You will see
- One of two batch devices fails, making `50.0% > 20.0% -> BREACH`; the timeline immediately pauses rollout and requests rollback to 2.3.1 for four devices.
- Why it matters
- The error-rate arithmetic beside the automatic actions proves why containment occurred and which state recovery requests.

Step 6 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab) Step 7
- Do
- Run `python3 main.py --step 7` to verify rollback acknowledgements and compare requested with reported firmware.
- You will see
- Four rollback acknowledgements precede a six-row table in which requested and reported versions are 2.3.1 and every drift value is NO.
- Why it matters
- Recovery is complete only after observed device state matches the rollback request, including unchanged excluded devices.

Step 7 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab) Step 8
- Do
- Run `python3 main.py --step 8` to print the incident record in event order.
- You will see
- The timeline moves from ALERT through DECISION, ERROR, CONTAIN, RECOVER, and VERIFY, then assigns the release-manager and a quarantine follow-up.
- Why it matters
- A chronological incident record connects signals to operator decisions, recovery evidence, ownership, and the next investigation.

Step 8 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab)
Chapter checks
These questions refer to the chapter’s examples. Use the return links to review their answers.
Why do production fleet problems differ from single-device testing?
Return to the chapter’s knowledge checkAfter an outage, why is a fixed 60-second reconnect delay (no jitter) still a problem?
Return to the chapter’s knowledge checkWhy can identical X.509 certificate expiry dates across a fleet cause an outage?
Return to the chapter’s knowledge check
Return to Production Architecture Case Studies · Browse Labs