Worker is stuck OOM'd
Summary
On August 16, k3s-agent-2 went from a memory warning to completely unresponsive within about two and a half hours. Load average reached 106 on a 2-CPU machine, with 118 MB of memory left, and yet the kernel’s out-of-memory killer never fired and Kubernetes never evicted anything. The node sat in a livelock for about 50 minutes and then recovered on its own.
Impact
- k3s-agent-2 was NotReady for about 50 minutes.
- Immich was down while its pod was stuck on the dead node, and its replacement on another node couldn’t attach its storage until the old pod died.
- Prometheus, which shared the node, was unavailable for the same period.
- No data was lost. All 11 Longhorn volumes returned to healthy on their own.
Detection
A HighMemoryUsage alert fired at 00:38 UTC. It escalated: the kubelet started returning errors on log and exec requests, then stopped reporting in, and the node went NotReady at 03:06.
Timeline (UTC)
| Time | Event |
|---|---|
| 00:38 | HighMemoryUsage for k3s-agent-2 |
| ~02:40 | Immich starts a background library job; its CPU use jumps 100× |
| ~03:00 | Node at 89% memory and 94% CPU; kubelet requests start failing |
| 03:06 | Node goes NotReady |
| ~03:11 | Immich is rescheduled elsewhere but can’t attach its volumes |
| 03:21 | SSH answers once: load 106, 118 MB available, no swap, no reboot |
| ~03:35 | Memory pressure readings show the node recovering; decision to wait |
| ~03:50 | The old Immich process dies, freeing about 6.6 GB |
| ~03:55 | Node Ready; volumes reattach; everything healthy |
Root cause
I had deployed Immich with no resource requests or limits. On an 8 GB worker that also ran Prometheus and the CosmicMS game server, that added up to about 6.6 GB of pods before the operating system. When Immich’s background job started, the node ran out of memory.
Why nothing was killed. The worker VMs run with no swap, which is the Kubernetes default. Without swap, the kernel can’t move ordinary memory to disk, so under pressure it throws away cached files, including the code of running programs, which then has to be read back in immediately. The machine spent all its time doing that. The out-of-memory killer only acts when reclaiming memory actually fails, and here it kept just barely succeeding. Most of that load average of 106 was processes stuck waiting for their own code to be read back from disk.
Why Kubernetes didn’t evict anything. Available memory settled at 118 MB, just above the kubelet’s default eviction threshold of 100 MB. So the node was thrashing, but it never quite crossed the line that would have made the kubelet evict a pod.
Diagnosis
- SSH was no use. It timed out during the connection handshake because the server couldn’t start a new process. It got through once in an hour.
- Proxmox’s guest agent still worked. Through it I could read the VM’s memory and pressure figures without logging in.
- Pressure stall information (PSI) gave the answer. Linux reports what share of time processes spent waiting on memory, averaged over 10 seconds, 1 minute and 5 minutes. The readings were 23%, 76% and 91%: the recent figure was far below the longer ones, so the node was digging itself out.
- I chose to wait. This node had a history of corrupted volumes after hard resets. The VM was still running, it hadn’t rebooted, and pressure was falling. It recovered about 20 minutes later and lost nothing.
Resolution and what changed
- Immich now has a 3 GB memory request and a 4 GB limit, plus CPU settings sized from a week of measured usage.
- The limit fixes the failure mode. If Immich hits its memory limit, the container gets killed and restarted right away, and the event shows up in Kubernetes. The whole node no longer starves slowly.
- The request fixes the scheduling. Before, the node reported 6% of its memory committed while actually at 89%. After, it reported 41%. On the next rollout the scheduler moved Immich to a better-balanced node on its own.
- The CoreDNS fix from incident 019, applied two hours earlier, held: DNS stayed up throughout, and no alerts were lost.
Lessons
- A node that runs out of memory with no swap may never see an OOM kill. It can livelock instead. Searching the kernel log for OOM kills turns up nothing and points you in the wrong direction. Pressure stall information is the better thing to look at.
- Falling pressure predicts recovery. Comparing the short and long averages tells you whether to wait or intervene.
- If SSH times out during the handshake, the machine may just be thrashing. Check the hypervisor before reaching for the reset.
- Requests and limits solve different problems. A limit keeps one container from taking down a node, and a request keeps the scheduler from overloading the node in the first place.
Takeaways for a prod environment
- Enforce memory requests and limits on every workload with an admission policy.
- Run a pressure-based out-of-memory handler such as systemd-oomd on nodes, so sustained pressure gets handled before the kernel’s last-resort OOM killer has to step in.
- Alert on memory pressure (PSI) per node, which shows this kind of trouble earlier and more clearly than percent used.