Nightly backups freezing the control plane
Summary
At 06:00 UTC on October 5, the nightly Proxmox backup started on all three hypervisors at once. Each hypervisor hosts one of the three k3s control-plane VMs, so all three etcd members were frozen and then slowed within seconds of each other. With no healthy member left to lead, etcd lost its leader three times in two and a half minutes, and all three Kubernetes API servers restarted. Nine minutes later, PagerDuty received a burst of crash-loop alerts for controllers that weren’t actually broken.
Impact
- About two and a half minutes without a working Kubernetes API.
- Every leader-elected controller in the cluster restarted: kube-state-metrics, the Longhorn CSI sidecars, the CloudNativePG operator, cert-manager and others, 10 containers across 5 namespaces.
- About five PagerDuty incidents for
PodCrashLooping, all clear within five minutes. - Running applications kept serving; their pods weren’t restarted. Nothing was lost.
Detection
PagerDuty paged on PodCrashLooping. The alerts pointed at the wrong layer, since none of those pods had a bug. What they all had in common was a leader lease held through the API server, which had just gone away.
Timeline (UTC)
| Time | Event |
|---|---|
| 06:00:01 | The backup job starts on all three hypervisors in parallel |
| 06:00:02–05 | All three etcd VMs are frozen for their snapshots, within 3 seconds |
| 06:00:14 | k3s on k3s-server-1, the etcd leader, exits after missing heartbeats |
| 06:00:35 | The new leader loses leadership; the cluster has no leader |
| 06:01:15 | Disk syncs still take 8 seconds, after the freeze has ended |
| 06:02:40 | The last of the three API servers restarts |
| 06:05:40 | Backups finish, taking twice as long as usual |
| 06:09:32 | PodCrashLooping pages for 10 containers |
| 06:14:32 | All clear |
| ~13:30 | Investigation starts |
| ~14:05 | Backup schedule changed |
Root cause
The cause came down to two settings in a backup job.
One job for everything, on every node at once. I had a single “back up all VMs at 02:00” job. Proxmox runs a cluster-wide job on every node in parallel, and I had deliberately placed one etcd VM on each node for high availability. So the schedule cancelled out that placement, and every night all three etcd members were frozen within the same few seconds.
Snapshot backups without fleecing. In snapshot mode, when the VM writes to a block that hasn’t been backed up yet, the old contents are copied out first. Without fleecing, that copy goes over the network to the backup server before the VM’s write can complete. That meant every disk write on the etcd VMs waited on the network for as long as the backup ran, long after the freeze itself had ended. etcd handles that badly, because it syncs every write to disk and gives up on a leader that stays slow for more than a few seconds.
Why that night. The same backup had frozen all three members every night for weeks. Usually one API server restarted at most, which looked like noise. On October 5, each control-plane VM had 2 to 2.5 times its usual changed data, so the backup ran twice as long, long enough for every member to lose leadership in turn.
Resolution
- The main nightly job now skips the three etcd VMs.
- Each etcd VM has its own job, 15 minutes apart, so at most one member is frozen at a time and the other two keep quorum and a leader.
- All jobs use fleecing to a local disk, so during a backup the VM’s writes wait on a local disk instead of the network.
- Every VM is still backed up nightly, with the same storage, mode and retention.
What changed
Verified over 29 nightly runs: no API server has restarted since, and no crash-loop alerts have fired. The rebuild guide was updated so a fresh install doesn’t recreate the single all-VMs job.
Lessons
- A cluster-wide schedule can undo high-availability placement. Spreading etcd across three hosts protects you when one host fails. It doesn’t help when a single backup job touches all three at once.
- Online snapshot backups can still hurt latency-sensitive workloads. The VM keeps running, but for the whole job its disk writes can only go as fast as the backup target.
- A nightly problem that hasn’t caused an outage yet probably will. Whether it did depended on how much data changed that day, and nothing was watching that.
- Lots of restarts at once usually point to the control plane. When every affected container is a leader-elected controller, look at etcd and the API server first. I had earlier raised the crash-loop threshold to quiet the small version of this, which also hid the trend.
Takeaways for a prod environment
- Back up etcd through its own snapshot mechanism on a schedule, independently of VM-level backups, and restore-test it.
- Do control-plane maintenance one member at a time, and require a good reason for anything that touches all of them at once.
- Alert on etcd leader changes and slow disk syncs directly, so control-plane stress shows up before applications start restarting.