The goal is to restore a working state quickly, protect data, and learn why the failure happened. The strategy depends on where the pipeline failed. Failure before production (build, tests, security scan) - Nothing is deployed, so no rollback is needed. The pipeline stops, the merge or release is blocked, and the team fixes forward with a new commit. This is why every stage must fail the pipeline on errors. Failure during deployment to an environment - With deployment slots (Azure App Service) or blue-green deployments: production traffic never moved to the new version; abort and keep the current slot live. - With rolling deployments on Kubernetes: the rollout stops when readiness probes fail; run kubectl rollout undo (or use automatic rollback with Argo Rollouts or Flagger). - Redeploy the last known-good artifact. Because pipelines build once and store versioned artifacts (image tags or package versions), rollback means deploying the previous version, not rebuilding old code. Failure after release (errors or performance regressions in production) - Slot swap back, or switch the load balancer back to the blue environment — usually seconds. - Turn off the feature flag for the new feature (fastest when the code itself is fine but a feature misbehaves). - Canary releases limit impact: only a small percentage of users see the new version, and automated analysis rolls it back on bad metrics. Database changes — the hardest part - Use backward-compatible migrations (expand and contract) so the previous application version still works with the new schema. Then rolling back the code does not require rolling back the database. - Avoid destructive changes (dropping or renaming columns) in the same release. - For data-corrupting failures, restore from point-in-time backups, rehearsed in advance. Process - Define rollback steps in the release runbook and automate them as a pipeline job. - Monitor health checks and key metrics right after deployment, with automatic rollback triggers where possible. - Communicate status to stakeholders. - Hold a blameless post-incident review and add tests or checks that would have caught the problem. Example answer: "We deploy to a staging slot and swap. If errors rise after the swap, we swap back within a minute. Migrations are backward compatible, so the old version keeps working, and we fix forward in the next release."
Ravindra Wadile · · 0 likes