SRE / Advanced: controlled failure and service readiness / Lesson 21
Design bounded automatic remediation
Define automation triggers, limits, verification, and recovery before enabling remediation.
On this page
Lesson goals
- Define action scope, preconditions, and retry limits.
- Test outcomes, failures, escalation, and recovery.
Define the automation contract
Automatic remediation needs an observable trigger, a specific target, an authorized action, and a measurable desired outcome. Write the assumptions and failure conditions before implementation. A service restart, for example, may reduce one symptom while losing in-flight work or repeating an operation. Begin with a disposable lab and synthetic workload; do not treat an alert alone as permission for a broad production action.
Bound the action
Limit the actionโs scope, frequency, concurrency, and permissions, and define a stop condition and human escalation path. The synthetic contract below identifies one lab target and a maximum attempt; it does not authorize a real restart. Ensure the automation can distinguish an intended target from similarly named resources. A repeated action can turn a temporary failure into a persistent outage if it has no cooldown or retry limit.
target: lab-service-1
trigger: synthetic health failure
action: one approved lab attempt
stop: repeated failure or unknown state
The example defines scope and limits; it performs no action.
Protect state and dependencies
Before acting, check the relevant workload state and dependencies using supported evidence. Define what happens if the previous action is still running or its result is unknown. An idempotent command is helpful but does not guarantee that downstream business effects or in-flight requests are safe. Retain a recovery path and avoid exposing secrets in automation logs. When the preconditions cannot be established, stop and escalate instead of guessing.
Verify the outcome
Measure the original user-facing symptom after the action, along with errors, capacity, and any affected data invariant. A successful command or healthy process state is not enough if the user operation still fails. The example verification record separates the action result from service recovery. Notify the accountable owner through the existing process and preserve the action, time, and evidence for review; do not claim a production result from a lab exercise.
action result: completed
user operation: verify separately
data invariant: verify separately
owner: lab responder
Action success is a separate state from user and data recovery.
Exercise failure and recovery
Test the automation in an isolated environment with a false trigger, a failed action, a repeated trigger, and an unavailable dependency. Verify that it stops or escalates within its defined limits and that a human can recover the system. Compare behavior with and without automation under the same synthetic workload. Review the contract after changes to dependencies or ownership, and assign unresolved risks before enabling any production action.
Common errors and fixes
Repeating an action without a limit
- Why it happens
- Automation has no cooldown or attempt bound.
- How to fix it
- Stop repetition and escalate to inspect state.
- Prevent it next time
- Define and test limits and a stop condition.
Treating command success as recovery
- Why it happens
- The user operation and data were not checked.
- How to fix it
- Repeat the original operation and inspect the affected invariant.
- Prevent it next time
- Tie verification to the service outcome.
Acting when state is unknown
- Why it happens
- Preconditions or a prior action result were not established.
- How to fix it
- Stop automation and gather evidence through the approved path.
- Prevent it next time
- Design a safe failure and explicit escalation.
2 practice exercises
1. A lab restart succeeded but requests still fail. Is the incident over?
Show worked solution
No. Inspect the user operation, dependencies, and data; record the result and escalate under the contract.
2. An alert repeats while an automated attempt is running. What behavior is needed?
Show worked solution
The tested contract should prevent unsafe overlap and apply a limit, cooldown, or escalation as designed.
Key takeaways
- Define trigger, target, limits, and rollback before automation.
- Verify user outcomes and test failure and escalation.