CI/CD · Ship safely, repeatedly
What is your rollback strategy for a bad deployment?
Short answer
Prefer redeploying the last known good artifact or disabling a feature flag, then forward-fix. Rollback must be tested, fast and compatible with data changes made by the bad version.
A rollback plan is only real if it has been exercised. The fastest path depends on the failure: a flag flip for a hidden feature, a traffic switch for blue-green, or a redeploy of the previous immutable artifact for a bad build.
- Keep the previous artifact and its configuration available and identifiable
- Use feature flags to disable risky behaviour without redeploying
- For containers, roll back to the previous ReplicaSet or digest
- Check database compatibility before rolling application code back
- Decide in advance whether the response is rollback or forward-fix, based on data impact
kubectl rollout history deployment/checkout
kubectl rollout undo deployment/checkout
kubectl rollout status deployment/checkout --timeout=5mFollow-ups you should expect
Interviewers use these to check whether the first answer was understanding or memorisation.
- 1When would you forward-fix instead of rolling back?
- 2How do you test a rollback?
- 3What if the rollback itself fails?
- 4How long should the previous artifact remain available?
Say it in the interview
My first choice is the fastest safe lever: turn off a flag, switch traffic back, or redeploy the previous immutable artifact. I keep the old artifact and configuration available and I test rollback regularly. The complication is data, because if the new version changed the schema incompatibly, code rollback may not be safe, so I use expand-and-contract migrations. Then I confirm recovery with the same metrics that detected the problem.
Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.
Related questions
Reading is step one
Now say it out loud.
Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live CI/CD mock interview and get scored feedback on depth, clarity and confidence.