Sub topic 3
Execute and record the rollback
This chapter assumes you can read a deployment manifest, query your monitoring system, and use git or a model registry. You have already chosen a known-good version and confirmed its artifact digest.
Execute and record the rollback
Pause the current rollout first so no new traffic reaches the faulty version. Then write an audit record before you change anything else. The record keeps the reason and the actor even if the rollback goes wrong.
import json
from datetime import datetime, timezone
def record_rollback(from_version, to_version, reason, operator, path="rollback_log.jsonl"):
entry = {
"timestamp": datetime.now(timezone.utc).isoformat(),
"from_version": from_version,
"to_version": to_version,
"reason": reason,
"operator": operator,
}
with open(path, "a", encoding="utf-8") as log:
log.write(json.dumps(entry) + "\n")
return entry
record_rollback("2026.03.15", "2026.03.08", "error rate above 2x baseline", "alice")Store the log in an append-only location. Do not delete the failed artifact, because you need it for root-cause analysis.
Validate health, predictions, and business behavior
Check three layers after the change. Service health covers error rate and p95 latency. Prediction health compares the output distribution with the pre-incident baseline. Business behavior compares a downstream metric, such as approval rate, against its expected range. Keep the validation window at least as long as the window that detected the regression.
Automate guarded rollback decisions and actions
Automate only decisions that rest on objective triggers. Require human approval for any action that moves more than a small canary slice of traffic. Write every automated action to the same audit log.
Rehearse rollback procedures
Run the full procedure in staging at least once per quarter. Time it, and note every step that required guessing. A failed rehearsal shows you more than a clean one does.
Complete incident follow-up and prevention work
Write a short incident report with the timeline, trigger, root cause, and rollback duration. List corrective actions with owners and due dates. Common items include a missing pre-deployment test, a tighter trigger threshold, or a schema check.
Exercise
Exercise
Your audit log shows a rollback from 2026.03.15 to 2026.03.08, but the artifact digest for 2026.03.08 does not match the registry. What should you do first?
Show answer
Stop the rollback and treat the artifact as untrusted. Do not deploy it. Confirm the digest from the registry and the provenance record, then choose another validated version or escalate.