Our label service runs as a Deployment, and for years our rollback has been kubectl rollout undo. The runbook said: if a release misbehaves, undo it first and investigate after.
On a Thursday this month version 4.17 went out at ten past two. Within minutes depot printers started rejecting a share of labels, and the engineer on call ran kubectl rollout undo. The pods went back to 4.16. Errors fell but did not stop, because jobs created under 4.17 were still working through the retry queue. Seeing errors under 4.16 as well, she concluded the fault was older and ran undo again to reach 4.15. Two minutes later the error rate was back where it had started. The second undo had deployed 4.17.
A Deployment's history is a list of pod templates, one per ReplicaSet, each numbered by revision. Before the incident 4.15, 4.16 and 4.17 were revisions 29, 30 and 31. Undo without arguments means the revision before the current one. The first undo did not create anything: Kubernetes found the ReplicaSet for 4.16, scaled it back up and gave it the next number, 32, and revision 30 vanished from the history. The revision before 32 was now 31, which was 4.17, so the second undo went there and renumbered it 33. Repeated undo switches between the last two versions. It never walks further back.
kubectl rollout history would have shown 29, 31 and 32 before the second command, but the column beside the numbers was empty because nothing set a change cause, and a list of bare numbers is not something anybody reads in the middle of an incident.
We no longer roll back with undo. Our rollback script takes a version, looks up its image in our release record and sets it on the Deployment, so going back two versions means naming the version. Every release sets the kubernetes.io/change-cause annotation to its version, so the history shows names, and reading it is the first step of the rollback runbook. When a release is rolled back, its retry queue is now moved to a holding queue, so errors left behind by the bad version are not mistaken for the old one's.
An undo command means whatever the tool's history means. Ours kept one copy of each version and renumbered it on every use, so undo was a switch between two states, not a step back.
– Sergey Shinder
Top comments (0)