Sub topic 12
Reviewing Incidents and Rehearsing Rollbacks
This chapter assumes you have read the earlier chapters of this tutorial. You should know how a model registry, a deployment pointer, rollback triggers, and post-rollback verification work. You should also be comfortable with Python, the command line, and basic Kubernetes. Here we cover what happens after the rollback: reviewing the incident, and practicing so the next rollback is faster and calmer.
Why review and rehearse
A rollback that works once proves little. Under pressure, people skip steps, forget which alias to move, or discover that the last known good version cannot be loaded anymore. Two habits address this:
- Post-incident review turns one bad release into changes that make the next one less likely and cheaper to recover from.
- Rollback drills test the whole path (trigger, decision, procedure, verification) before a real incident forces you to.
Both feed the same loop. Drills find weaknesses in a safe setting. Incident reviews find weaknesses that drills missed. Fixes from either one go back into the runbook, the automation, and the monitoring.
Running a blameless post-incident review
A review asks what in the system and the process allowed the failure and slowed recovery. It does not ask who made a mistake. People who fear blame hide details, and hidden details are exactly what you need. Hold the review within a few days of the incident, while memory and logs are fresh.
Build a timeline first
Start with facts in time order, taken from logs, deployment history, and chat records, not from memory. For a model rollback, mark these moments:
- The new version was registered, and then promoted or deployed.
- The first user-visible or metric-visible symptom appeared.
- An alert fired, or a person noticed.
- Someone decided to roll back.
- The pointer was moved or the deployment was undone.
- Verification showed recovery.
The gaps between these moments are the useful numbers. Common names for them:
| Interval | Between | What a long gap suggests |
|---|---|---|
| Time to detect | Symptom starts and alert or human notice | Missing or weak monitoring, thresholds too loose |
| Time to decide | Detection and decision to roll back | Unclear triggers, unclear ownership, debate over rolling forward |
| Time to execute | Decision and pointer change | Manual steps, missing access, unclear runbook |
| Time to recover | Pointer change and verified healthy | Slow reloads, cached predictions, long rollout, dependency problems |
Record the numbers even when they look fine. A trend across incidents and drills is more informative than any single value.
Separate causes into layers
An ML incident usually has more than one cause. Sort what you find into layers so the action items cover each one:
- Why the bad version reached production. Offline evaluation missed a case, a test dataset was stale, a canary was skipped, or the canary was too small to show the problem.
- Why it was not caught sooner. The signal existed but had no alert, the alert went to the wrong channel, or the model quality metric depends on labels that arrive days later.
- Why recovery took as long as it did. The runbook was out of date, the serving layer did not reload after the alias change, or the old version needed a feature that no longer existed.
Avoid stopping at "human error". Ask what made the error easy to make and hard to notice, then fix that.
Write action items that can be checked
Each action item needs an owner, a due date, and a way to tell whether it is done. Compare:
- Weak: "Improve monitoring."
- Better: "Add an alert on prediction score distribution shift for
fraud-detector, paging the on-call, owner: A. Rivera, due in two weeks."
Prefer changes that remove a manual step or add a guard over changes that say "be more careful". Examples include a registry check that blocks promotion without a recorded evaluation, or a deployment gate that requires a canary stage.
What to record about each rollback
A short, structured record makes reviews and trend tracking easier. A plain file or ticket template is enough. The example below captures the fields from the timeline and writes them as JSON. It uses only the Python standard library, so it runs as shown.
import json
from datetime import datetime, timezone
def minutes_between(start_iso, end_iso):
start = datetime.fromisoformat(start_iso)
end = datetime.fromisoformat(end_iso)
return round((end - start).total_seconds() / 60, 1)
def build_rollback_record(model, from_version, to_version, events, reason):
"""events maps names to ISO 8601 timestamps with a timezone offset."""
return {
"model": model,
"from_version": from_version,
"to_version": to_version,
"reason": reason,
"events": events,
"minutes_to_detect": minutes_between(events["symptom_start"], events["alert_fired"]),
"minutes_to_decide": minutes_between(events["alert_fired"], events["decision"]),
"minutes_to_execute": minutes_between(events["decision"], events["pointer_changed"]),
"minutes_to_recover": minutes_between(events["pointer_changed"], events["verified_healthy"]),
}
record = build_rollback_record(
model="fraud-detector",
from_version="4",
to_version="3",
reason="p95 latency above limit after promotion",
events={
"symptom_start": "2026-11-20T09:02:00+00:00",
"alert_fired": "2026-11-20T09:09:00+00:00",
"decision": "2026-11-20T09:15:00+00:00",
"pointer_changed": "2026-11-20T09:21:00+00:00",
"verified_healthy": "2026-11-20T09:33:00+00:00",
},
)
print(json.dumps(record, indent=2))In this example, detection took 7 minutes, the decision 6, execution 6, and recovery 12. Execution of six minutes for a one-line alias change would be a finding. It suggests missing access, an unclear runbook, or a manual approval step worth reviewing.
Rehearsing rollbacks with drills
A drill is a planned exercise where the team performs the rollback procedure without a real emergency. The goal is to find problems in the procedure, not to grade people.
Choose a drill type
| Drill type | What you do | What it tests |
|---|---|---|
| Tabletop | Talk through a scenario step by step, with no systems touched | Roles, decisions, runbook clarity |
| Staging rollback | Deploy a version to a staging environment, then roll back | Procedure, registry access, reload behavior, compatibility checks |
| Production rollback with a known good version | Roll back to a recent healthy version during a quiet period, under watch | Real permissions, real traffic, real verification |
| Fault injection | Release a deliberately degraded model to a canary and let triggers fire | Monitoring, thresholds, automated rollback |
Start with tabletop and staging drills. Move to production drills only when the procedure is stable and you can limit the exposure, for example by using a canary slice of traffic or a low-traffic window.
Plan a drill
- Pick a scenario. Examples: latency regression, a feature that now arrives as null, a model that scores everything near zero, or a registry outage during the incident.
- State the success criteria in advance. For example: "Production alias points to the previous version within 10 minutes of the decision, and error rate returns to baseline within 15 minutes."
- Assign roles. One person runs the procedure, one person watches dashboards, and one person keeps the timeline. Rotate roles between drills so more than one person knows the whole path.
- Run it with the real runbook. If someone says "I just know how to do that", write the step down.
- Hold a short review. Record timings, surprises, and action items, the same way as for a real incident.
Scripting a staging drill
A drill is easier to repeat when most of it is a script. The script below runs a rollback against a staging registry, then checks that the serving endpoint reports the expected version. It assumes your serving layer exposes the loaded model version at a /version endpoint that returns JSON with a version field, and that it reloads on a timer or on request. Adapt the endpoint and the wait to your setup.
import json
import time
import urllib.request
from mlflow import MlflowClient
MODEL_NAME = "fraud-detector"
ALIAS = "production"
TARGET_VERSION = "3"
VERSION_URL = "http://staging-model-server.internal/version"
TIMEOUT_SECONDS = 300
POLL_SECONDS = 10
def served_version():
with urllib.request.urlopen(VERSION_URL, timeout=5) as response:
return str(json.load(response)["version"])
def run_drill():
client = MlflowClient()
started = time.monotonic()
before = client.get_model_version_by_alias(MODEL_NAME, ALIAS).version
print("Alias before drill:", before)
client.set_registered_model_alias(MODEL_NAME, ALIAS, TARGET_VERSION)
pointer_changed = time.monotonic()
while time.monotonic() - pointer_changed < TIMEOUT_SECONDS:
try:
if served_version() == TARGET_VERSION:
recovered = time.monotonic() - started
print(f"Serving version {TARGET_VERSION} after {recovered:.0f}s")
return True
except OSError as error:
print("Endpoint not ready:", error)
time.sleep(POLL_SECONDS)
print("Drill failed: endpoint did not report the target version in time")
return False
if __name__ == "__main__":
raise SystemExit(0 if run_drill() else 1)The script exits with a non-zero status when the endpoint does not reach the target version in time, so a scheduler or CI job can report the failure. After the drill, move the alias back to before if staging should return to its earlier state.
Things drills commonly uncover
Teams that run their first drills often find problems like these:
- The previous version cannot be loaded. The artifact was deleted by a retention policy, or its dependencies no longer install. Fix: pin retention for versions marked as rollback candidates, and keep the environment spec with the artifact.
- The serving layer never reloads. The alias moved, but pods still hold the old model in memory. Fix: define a reload or restart step, and verify with the version endpoint, not with the registry alone.
- Features have changed. The old model expects a column that the feature pipeline no longer produces. Fix: run the compatibility check from the earlier chapter as part of the runbook.
- Access is missing. The on-call engineer can read the registry but cannot change aliases or restart deployments. Fix: grant and test the permissions ahead of time.
- The runbook names things that no longer exist. Old cluster names, renamed models, retired dashboards. Fix: give the runbook an owner and a review date.
- Verification relies on delayed labels. Accuracy cannot confirm recovery for days. Fix: define shorter-term checks such as error rate, latency, and prediction distribution, and state which ones count as "recovered".
- Alerts reach nobody. The paging route points at a retired channel. Fix: test alert routing as part of the drill.
Keeping the practice sustainable
Reviews and drills are only useful if they continue. A few guidelines keep the cost reasonable:
- Run a staging drill on a regular schedule, such as every quarter, and after any major change to the serving stack, registry, or feature pipeline.
- Run one whenever the team changes enough that the previous drill no longer reflects who is on call.
- Review near misses as well as outages. A canary that caught a bad version is a success worth studying, because it shows which defenses worked.
- Track the interval metrics over time. If time to execute falls from 20 minutes to 3 after you script the procedure, you have evidence the work paid off.
- Close action items. A review with open items that nobody owns teaches the team that reviews do not matter.
Summary of the practice
After a rollback, build a fact-based timeline, measure the four intervals, sort causes into layers, and write action items with owners. Then rehearse the procedure in staging, with explicit success criteria, rotating roles, and the real runbook. Feed what you learn back into triggers, automation, compatibility checks, and access. Over time, rollback becomes a routine operation that the team trusts.
Exercise
During a drill, the alias moves to version 3 within 2 minutes, but the version endpoint still reports version 4 after 10 minutes. Name two likely causes and one runbook change that would prevent this in a real incident.
Show answer
Likely causes: the serving layer loads the model only at startup and was never restarted or reloaded, or it caches the model and has a long refresh interval. Another possibility is that the endpoint reports a stale value, or the deployment loads by a fixed version instead of by alias. A runbook change: add an explicit step to restart or trigger a reload of the serving pods after the alias change, and make verification read the version from the serving endpoint rather than from the registry.
Exercise
A review lists the action item "Be more careful when promoting models." Rewrite it as an action item that can be checked, and say what type of change it is.
Show answer
For example: "Add a registry promotion check that rejects any version without a recorded evaluation report and a passed canary stage. Owner: the ML platform lead. Due: two weeks." This is a guard that removes reliance on individual care, so it is better than a reminder to be careful. It has an owner, a date, and a testable condition.
Exercise
A rollback record shows detect 4 minutes, decide 25 minutes, execute 3 minutes, recover 8 minutes. Which interval deserves the most attention, and what questions would you ask?
Show answer
Time to decide, at 25 minutes. Ask whether the rollback triggers were defined and agreed in advance, who had the authority to decide, whether the team debated rolling forward instead, and whether the alert gave enough information to act on. Fixes could include clearer thresholds, a named decision owner, or automated rollback for clear-cut triggers.