B. Blue Green a software delivery tutorial
Vol. I § Zero-downtime series § A series for junior developers
Zero-downtime delivery · 10 / 10 ·

Rollback moves the switch back

Even a perfect deploy someday needs to be undone. The good news: in this architecture, rollback is not a separate mechanism you have to write from scratch. It is an ordinary deploy that happens to target an old version.

The old slot still holds v1.2.3. The playbook patches Caddy back to that port, then writes state.json.

Slot playground · rollback
readerCaddy :8080blue :18080 · upgreen :18081 · up
Green is live, but the new version is wrong.
  1. Green is live, but the new version is wrong.
  2. Caddy returns to blue. The old version is still in state.json.

Drain mode shows in-flight requests finishing their work before the old slot stops.

Slot playground · drain
readerCaddy :8080blue :18080 · upgreen :18081 · up
New traffic goes to green. Blue still finishes old requests.
  1. New traffic goes to green. Blue still finishes old requests.
  2. Old requests finished. Blue is stopped.

Quick recap

  • Rollback is a normal deploy with an old tag; the path, the health check, and the switch are identical.
  • Drain gives in-flight requests time to finish before the old slot stops.
  • The precondition for rollback: the old image still exists in the registry.
  • rollback_available and state.json.bak always tell you the real state of things.

If a new release fails its health check, you never reach this chapter. The health gate already kept readers on the old version.

Reader notes

Chapter discussion appears once Giscus is connected to the site repository.