Deployment Failure Playbook
This playbook provides a structured guide for identifying causes of deployment failures, implementing mitigations to prevent or minimize them, and conducting drills to build team resilience. It's designed for engineering teams using CI/CD pipelines (e.g., GitHub Actions, Jenkins, ArgoCD) and cloud infrastructure (e.g., AWS, Kubernetes).
The playbook is organized by failure categories. Use it during incident response, retrospectives, and training.
1. Build and Test Failures
Failures during compilation, unit/integration tests, or artifact generation.
Causes
- Dependency mismatches (e.g., npm/yarn lockfile drift).
- Flaky tests due to race conditions or external dependencies.
- Resource exhaustion (e.g., CI runner OOM kills).
- Upstream library regressions.
Mitigations
- Lock dependencies: Use
package-lock.json, poetry.lock, or equivalent; run npm ci in CI.
- Quarantine flaky tests: Tag and run them separately; aim for <1% flakiness.
- Scale CI resources: Auto-scale runners; use spot instances with fallbacks.
- Test in isolation: Mock external services; use contract testing (e.g., Pact).
Drills
- Chaos Test Injection: Script to inject flaky test failures (e.g., via test-framework hooks). Time: 30 min. Goal: Validate retry logic.
- Tabletop: Simulate a flaky test blocking prod deploy. Discuss: Who notifies? Rollback threshold?
2. Deployment Pipeline Failures
Failures in staging/prod rollout (e.g., Helm/K8s apply, Terraform).
Causes
- Configuration drift (e.g., infra-as-code vs. live state).
- Image/tag mismatches (wrong Docker image pushed).
- Approval gate timeouts or human errors.
- Network/policies blocking (e.g., VPC peering issues).
Mitigations
- GitOps: Use declarative tools like ArgoCD/Flux for drift detection and auto-healing.
- Multi-stage gates: Canary/blue-green deploys with traffic shifting (e.g., via Istio/FLA).
- Image promotion: Semantic versioning + registry scanning (e.g., Trivy for vulns).
- Pre-flight checks: Dry-run deploys + smoke tests before full rollout.
Drills
- Pipeline Sabotage: Manually break a pipeline step (e.g., bad tag). Practice: Detect, fix, resume. Time: 45 min.
- War Games: Team A breaks deploy; Team B responds. Rotate roles. Metrics: MTTR <15 min.
3. Runtime Post-Deployment Failures
App crashes, high latency, or errors after deploy.
Causes
- Resource limits exceeded (CPU/memory spikes).
- Database/schema mismatches.
- Third-party service outages (e.g., API rate limits).
- Circuit breaker failures under load.
Mitigations
- Autoscaling & limits: HPA/Pod Disruption Budgets; set requests/limits conservatively.
- Database migrations: Use zero-downtime tools (e.g., Liquibase, online schema change).
- Circuit breakers & retries: Libraries like Resilience4j/Polly; fallback stubs.
- Observability: Full-stack monitoring (Prometheus/Grafana + distributed tracing via Jaeger).
Drills
- Load Storm: Use k6/Locust to spike traffic post-deploy. Simulate DB outage. Goal: Trigger alerts, scale, recover.
- Game Day: Quarterly full-sim: Deploy "broken" version, observe chaos. Debrief: What broke? playbook gaps?
4. Rollback Failures
Inability to revert to previous version.
Causes
- Destructive changes (e.g., data migrations without reverse).
- State loss (e.g., stateless apps with lost sessions).
- Rollback amplifies issues (e.g., version incompatibilities).
- No rollback plan (ad-hoc deploys).
Mitigations
- Immutable deploys: Always deploy new artifacts; never mutate prod.
- Reversible changes: Feature flags (e.g., LaunchDarkly) + shadow DB migrations.
- Automated rollback: CI/CD with
kubectl rollout undo or ArgoCD sync back.
- Backup strategy: Snapshot DBs/volumes pre-deploy; test restores.
Drills
- Rollback Relay: Deploy v2 (known bad), trigger rollback to v1. Time it end-to-end. Repeat with complications (e.g., DB changed).
- Failure Chain: Chain failures: Deploy → Runtime fail → Rollback fail. Practice escalation to on-call + postmort.
General Best Practices
- On-Call Rotation: PagerDuty/Slack alerts for deploy failures; 15-min SLA for ACK.
- Postmortems: Always BLAMELESS; template: Timeline, Root Cause, Actions.
- SLOs: Define Deploy SLO (e.g., 99% success rate); track via dashboards.
- Tools Stack: GitHub/GitLab CI, Kubernetes/Helm, Datadog/New Relic for monitoring.
Playbook Maintenance
- Review quarterly or post-major incident.
- Version control this doc in your repo.
- Assign owners: Causes (Dev), Mitigations (DevOps), Drills (SRE).
Run your first drill today: Pick one category and simulate! If you need templates/scripts for any section, let me know. 🕵️♂️