DEV Community

Riley Wu
Riley Wu

Posted on

Your Rollback Restores the Pod, Not the Outbox

Your Rollback Restores the Pod, Not the Outbox

A Kubernetes Deployment rollback is narrower than its name suggests. The official documentation says a Deployment creates a revision on a Pod template change, scaling alone creates no revision, and rollback to an earlier revision restores the Pod template; it does not reverse unrelated database changes (Deployment docs). Queued work and migrated rows lie outside it. A model route or allowlist may ride in the template. Rollback restores configuration, not work already produced under it.

Steps

  1. Define the effect boundary: what could the service write during the rollout window?
  2. Record the current revision from rollout history.
  3. For each effect, define one compensating action: drain a queue, tombstone a row, or re-run pinned configuration. This is proposed practice, not Kubernetes behavior.
  4. Rehearse in a scratch namespace with a seeded queue and controlled consumer.

An outbox item enqueued under the old configuration may execute after rollback under the restored one, depending on the consumer. Decide whether to drop it, re-derive it, or run it against its original configuration. State the choice; silence is how duplicates appear. This is a design decision, not a claim that rollback creates duplicates.

Test

Use a scratch namespace with three seeded outbox items, one seeded response row, one controlled consumer, and no other traffic. Pause the consumer before observing queue depth; otherwise it can drain the queue. Change only the Pod template: expect a new revision. Change only replica count: expect no new revision. Roll back. With the consumer still paused, inspect queue depth and the response row.

Expected: the Pod template returns to the earlier revision; queue depth remains three; the response row remains. If queue depth falls, the pause is incomplete or another consumer exists; identify it before trusting the observation. If the response row disappears, a data restore occurred, not a rollback; check for an unplanned migration hook. If a scale-only change produces a revision, verify whether the Pod template actually changed. Resume the consumer after recording results.

Limits

This works when effects are enumerable and cheap to compensate. Irreversible effects such as sent email, charged cards, or published artifacts need a quarantine window before the effect, not a rollback after it.

This article was created with AI assistance.

Top comments (0)