Video in progress
A new release caused a problem in prod. Do you `git revert` and redeploy, redeploy the old version, or roll forward? Which one, and when?
The first step is almost always to redeploy the previous, tested artifact. That is fast and does not depend on Git. Then on main I either revert the bad commit or move forward with a fix. If the migration is not backward compatible, only roll forward is left.
📖 Answer
In an emergency I work with the artifact, not with Git. The previous image digest exists and has already run in prod, so bringing it back takes a few minutes. Rebuilding from an old tag is slower and riskier: the dependencies, the base image or the build tool may have changed in the meantime, and the "old" version turns out to be a new binary.
But rolling back the artifact is not enough. main still holds the broken code, and the next deploy will bring it out again. So the second step:
git revert -m 1 <PR-merge-commit> # or a plain revert if it was squashed
git push origin main # through a PR, with CI
What to do when:
| Situation | Path |
|---|---|
| The bug is unclear, and the impact on users is big | the previous artifact, then analysis |
| The bug is in code behind a feature flag | turn the flag off, the fastest |
| The fix is one line, and the pipeline takes 10 minutes | roll forward |
| A migration dropped a column or changed data | roll forward only |
The last row is the most painful. That is why I do DB changes with expand/contract: release N adds the new column and writes to both, and the old column is dropped only in N+2. That way release N can be rolled back freely.
In a release branch model, the revert is needed on the release branch too, and goes out with a new patch tag (v2.7.1). I do not move the existing v2.7.0 tag, because it has to show what was deployed.
Sign up to mark studied questions and save your progress.