tezvyn:

Deployment Rollbacks: Your CI/CD Undo Button

AI-drafted, machine-checkedSource: docs.gitlab.combeginner

A rollback strategy is your CI/CD's undo button, letting you revert to a known good state when a new deployment fails. It's essential for production environments. The biggest mistake is not having one, forcing a frantic 'hotfix' under pressure.

WHY IT EXISTS Software is complex, and even with extensive testing, new deployments can fail in production. A rollback strategy exists to minimize downtime and business impact by providing a fast, predictable way to return to a working state, without needing to immediately debug and patch the new, broken code under pressure.

THE MENTAL MODEL Think of it like version control for your live application. Just as you can revert a bad commit in Git, a rollback strategy lets you "revert" a bad deployment. Instead of pushing a new fix forward, you go backward to the last version that was known to work. It's a safety net that separates the act of restoring service from the act of fixing a bug.

HOW IT WORKS CI/CD platforms like GitLab manage this through the concept of "environments" (e.g., 'production', 'staging'). Each time you deploy, the platform records that deployment event, creating a historical list. A rollback is typically not a new, special process. Instead, it's simply re-running a previous, successful deployment job from that history. The CI/CD system executes the exact same steps it did for the last good version, overwriting the broken one. This deployment history is the key; without it, you don't know what "good" looked like or how to get back to it.

WHEN TO USE IT Use a rollback strategy for any environment where stability is critical, especially production. It is the first line of defense when monitoring alerts fire immediately after a deployment. It buys you time to diagnose the problem offline without ongoing customer impact. It's also useful in staging environments to quickly undo a change that's blocking other testing.

WHEN NOT TO USE IT A rollback is not a substitute for fixing the underlying bug; it's a temporary measure to restore service. Also, be wary of rollbacks if a deployment included irreversible database schema migrations. Reverting the application code without a corresponding database change can cause even more severe failures. This is a major footgun that requires careful planning.

ONE CANONICAL EXAMPLE A team deploys a new feature. Immediately, error rates spike. Instead of trying to debug the live system, the on-call engineer navigates to the GitLab 'Environments > production' page. They see a list of deployments and identify the previous, stable one. They click 'Re-deploy' on that old job. The CI/CD pipeline re-runs the job for that older, stable version, restoring the application. The crisis is over, and the team can now analyze the failed deployment offline.

Read the original → docs.gitlab.com

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.