Exit code 137: meaning and how to fix it (Kubernetes, Docker)

Exit code 137 means SIGKILL, and it is not always out of memory. Six causes reproduced on Kubernetes 1.37 and Docker, told apart from real output.

Ben Gervais
Ben Gervais, Engineer at Arvo AILinkedInGitHub
Applies toAny process that exits 137: Kubernetes containers (Exit Code: 137), Docker and Compose containers, docker build steps, and plain Linux shells and services
Verified onKubernetes server v1.37.0 (kindest/node:v1.37.0), kind v0.33.0, kubectl client v1.37.2, containerd v2.3.4, Docker Engine 28.0.4, cgroup v2, kernel 7.0.0-1017-azure on a GitHub Actions Ubuntu runner, python:3.12-alpine, busybox:1.37, 2026-11-05
Lab folderscenarios/22-exit-137-not-oom, captured output in runs/search-2026-11-05/22-exit-137-not-oom

Exit code 137 means the process was killed by SIGKILL: 128 plus signal number 9. It does not by itself mean the process ran out of memory, because the kernel OOM killer, the kubelet at the end of a grace period, docker stop, docker kill and a plain kill -9 all produce it. In Kubernetes, read lastState.terminated.reason: OOMKilled means the kernel OOM killer, and Error with 137 usually means something else ended the container, such as a process that did not stop on SIGTERM before terminationGracePeriodSeconds ran out. In Docker, read State.OOMKilled in docker inspect. Raise a memory limit only after that field says memory. For OOM causes and fixes, go to OOMKilled; this page covers telling the 137s apart.

kubectl get pod <pod> -o jsonpath='{range .status.containerStatuses[*]}{.name}{"\t"}{.lastState.terminated.reason}{"\t"}{.lastState.terminated.exitCode}{"\n"}{end}'

At a glance

SignalLikely causeConfirm withFix
Reason: OOMKilled, a memory limit is setContainer went over its limitoom above 0 in the pod's memory.eventsOOMKilled runbook
Reason: OOMKilled, no limit set, SystemOOM event on the NodeThe whole node ran out of memoryKernel log: Out of memory: Killed process, global_oomSet memory requests and limits, fix node capacity
Reason: Error, Killing event says failed liveness probeProbe failed and the process did not stop on SIGTERMUnhealthy and Killing events; Finished is one grace period after the killFix the probe, handle SIGTERM
kubectl delete or a rollout takes exactly the grace periodProcess ignores SIGTERM. Often no handler as PID 1, or a shell that does not forward itcontainerd log shows Kill containerHandle SIGTERM, or exec from the shell
Logs show shutdown started, then stopDrain takes longer than the grace period, or preStop used it upApp log; FailedPreStopHook eventRaise terminationGracePeriodSeconds to cover it
Pod Reason: EvictedNode-pressure evictionPod Message, see OOMKilledSet requests near real usage
Reason: Error, 137, no Killing event, oom_kill 0Something on the node sent SIGKILL, or the program returned 137 itselfProgram's wrapper and the node's agentsFind the sender or the wrapper
Reason: Error, 137, oom_kill above 0An OOM kill recorded as ErrorPod's memory.events, kernel logTreat as OOM
Docker "OOMKilled":false, 137docker kill, or docker stop past its timeoutdocker events: kill signal=9Handle SIGTERM, or docker run --init

What does exit code 137 mean?

A shell reports a process killed by a signal as 128 plus the signal number. The Bash manual says: "When a command terminates on a fatal signal whose number is N, Bash uses the value 128+N as the exit status." SIGKILL is signal 9, so 128 + 9 = 137. Container runtimes report the same number. You can make one in any shell:

$ bash -c 'sleep 100 & kill -9 $!; wait $!; echo status $?'
bash: line 1: 49507 Killed                  sleep 100
status 137

The number tells you how the process ended. It says nothing about who sent the signal or why. A process cannot catch SIGKILL, so it leaves no shutdown log line, and that is why these incidents look alike: the log stops mid-sentence and the exit code is 137.

Is exit code 137 always out of memory?

No. On one cluster on 2026-11-05 we produced 137 from a container limit, a full node, a failed liveness probe, a kubectl delete, a SIGKILL from the node and a program that returned 137 without any signal. Only the first two involved memory. Memory may still be the most common cause in the field; we have no data on that. The check costs one command, and the fixes do not overlap. This matrix comes from one run, and it is the reason to check reason first:

What ended the containerreasonPod eventsPod memory.events on the nodecontainerd log
Over its memory limitOOMKilledNothing about the killoom 1, oom_kill 2, oom_group_kill 1TaskOOM event
Node out of memory, no limitOOMKilledSystemOOM on the Nodeoom 0, oom_kill 2, oom_group_kill 1Not captured
Liveness failure, SIGTERM not handledErrorKilling: failed liveness probe, will be restartedAll 0Stop container, then Kill container 10 s later
kubectl delete, SIGTERM not handledError, then the pod is goneKilling: Stopping container appNot capturedStop container, then Kill container 10 s later
kill -9 from the nodeErrorNothing about the killAll 0No stop or kill line
Program ran exit 137ErrorBackOff onlyAll 0No stop or kill line

Our control was a process that handles SIGTERM. It failed the same liveness probe and ended with Completed, exit 0, in the same run. A probe kill is a 137 only when the process does not stop in time.

Three other facts decide which checks are worth running:

  • Our cluster logged no event for a container OOM kill. The pod's events showed only Scheduled, Pulled, Created and Started, and the Node had no SystemOOM. Absence of an OOM event proves nothing, so read reason.
  • reason can miss an OOM kill. Across three runs we forced 240 pods over their limit, each allocating 150 MiB under 128Mi with no probe: 238 recorded OOMKilled and 2 recorded Error, both with exit code 137. Nothing else in those pods could send SIGKILL, and the kernel logged its usual 80 lines in both rounds that held an Error. The likely cause is the one in containerd issue #12260, a test flake with the same symptom: a contributor proposed that the exit update can land before the OOM update, and later that systemd removes the cgroup first. That issue was closed as stale with no fix. We kept only the counts for those two pods, so we cannot say which one we hit. Do not read 2 of 240 as a rate; a loaded host gave 3 of 40, on the OOMKilled page. We saw no case of the reverse, OOMKilled without a kill, but we did not check pod by pod.
  • 137 is sometimes just a return value. Scripts that do exit $? pass on a child's status, so the signal may have hit a child, or nothing at all.

How do you tell what killed the container?

Work from cheap to expensive, and stop when you have an answer.

1. Read the reason. Our real OOM kill and our liveness kill, same fields:

oom-limit	1	OOMKilled	137	2026-11-05T22:14:54Z	2026-11-05T22:15:14Z
worker-6df4dfbb9f-g5d8k	3	Error	137	2026-11-05T22:13:24Z	2026-11-05T22:13:44Z

(Columns: name, restarts, reason, exit code, started, finished. The same command on two pods.)

2. Read the events, soon. Events expire, so a kill from yesterday may have none left. The shop worker in scenario 22, after a release added a liveness probe on a file nothing writes:

    Last State:     Terminated
      Reason:       Error
      Exit Code:    137
      Started:      Thu, 05 Nov 2026 22:13:24 +0000
      Finished:     Thu, 05 Nov 2026 22:13:44 +0000
    Ready:          True
    Restart Count:  3
    Limits:
      memory:  192Mi
...
  Normal   Killing    16s (x3 over 56s)  kubelet            spec.containers{worker}: Container worker failed liveness probe, will be restarted
...
  Warning  Unhealthy  1s (x7 over 61s)   kubelet            spec.containers{worker}: Liveness probe failed:

(Trimmed where marked.) kubectl top showed the same worker at 3Mi against a 192Mi limit:

POD                       NAME     CPU(cores)   MEMORY(bytes)   
worker-6df4dfbb9f-g5d8k   worker   11m          3Mi             

3. Read memory.events on the node, for the pod. The kernel keeps this counter, so it does not depend on the update that can lose reason. We have not caught it on an Error pod: the tally deleted those pods without reading it. It has to be the pod's cgroup. The counter inside the container resets, because the replacement gets a new cgroup. On the same pod, seconds after a real OOM kill:

$ kubectl -n exit137 exec oom-limit -- cat /sys/fs/cgroup/memory.events
low 0
high 0
max 0
oom 0
oom_kill 0
oom_group_kill 0
sock_throttled 0

And the pod-level file on the node:

low 0
high 0
max 37
oom 1
oom_kill 2
oom_group_kill 1
sock_throttled 0

On a systemd-driver node, find it with the pod's UID, dashes replaced by underscores:

kubectl get pod <pod> -o jsonpath='{.metadata.uid}'
find /sys/fs/cgroup -type d -name '*pod<uid_with_underscores>*'
cat <that path>/memory.events

The kernel documentation defines oom_kill as "The number of processes belonging to this cgroup killed by any kind of OOM killer." and oom_group_kill as "The number of times a group OOM has occurred." We got oom_kill 2 for a single process and the kernel log printed its line twice, so count incidents with oom_group_kill. The pair also separates a limit from a full node: oom 1 here, oom 0 with oom_kill 2 when the node ran out. A pod with oom_kill 0 was not killed by the OOM killer, whatever else happened. Above 0 is weaker: the kernel docs say these fields are hierarchical, so the pod file adds up every container and every earlier kill, and a child process or a sidecar counts too. Compare it across restarts. The pod cgroup goes away with the pod.

We read this with docker exec on a kind node. On a real node use SSH or kubectl debug node/<node> -it --profile=sysadmin --image=busybox:1.37, then chroot /host; we did not run that form.

4. Read the kernel log on the node.

dmesg | grep -E 'oom-kill:|Killed process'

A container limit:

[  854.409421] oom-kill:constraint=CONSTRAINT_MEMCG,nodemask=(null),cpuset=cri-containerd-80d13a8258f81d944dbb2d39faaee7c4869d239353e1c85a690326ab66e63fd5.scope,mems_allowed=0,oom_memcg=/system.slice/docker-a2c2f06dc068d9b58055f3e8e590bcbebc9e514870d2d73d5af513fc22477423.scope/kubelet.slice/kubelet-kubepods.slice/kubelet-kubepod
[  854.409494] Memory cgroup out of memory: Killed process 21786 (python) total-vm:164844kB, anon-rss:130124kB, file-rss:5440kB, shmem-rss:0kB, UID:0 pgtables:316kB oom_score_adj:992

A full node, with a pod that has no limit at all:

[ 1043.203744] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=containerd.service,mems_allowed=0,global_oom,task_memcg=/system.slice/docker-e5ddbd8a44d43a9818d46eea775d414644d8ca647e87e3437aa1f042a7d48a91.scope/kubelet.slice/kubelet-kubepods.slice/kubelet-kubepods-besteffort.slice/kubelet-kubepods-besteffort-pod7bc8e21d_f03a_4212_8d53_b2cf6dc53aa9.slice/cri-containerd-44d7c72bde6c451a0c6c21fdb5afa0501b204f
[ 1043.203801] Out of memory: Killed process 50766 (python) total-vm:14347508kB, anon-rss:14331684kB, file-rss:8kB, shmem-rss:0kB, UID:0 pgtables:28112kB oom_score_adj:1000

(oom-kill: lines are cut at the right: the first by us, the second when captured. The limit example is the Kubernetes child-process test described under Docker below. Add -T to dmesg for wall-clock times.) CONSTRAINT_MEMCG with Memory cgroup out of memory is a limit. A limit on a parent cgroup looks the same: when we capped the kind node's own container, the kernel said CONSTRAINT_MEMCG and the pod said oom 0, oom_kill 2. CONSTRAINT_NONE, global_oom and Out of memory is the node. In that second example the pod recorded OOMKilled, 137 and an empty resources, and it was killed 7 seconds after it started, with held 13800 MiB as its last log line. There was no Evicted event. kubectl describe node still read MemoryPressure False, but that condition's last heartbeat was 22:15:36 and the kill was at 22:18:25, so it shows only that the kubelet had reported no pressure, not that it checked during those 7 seconds. As the eviction docs put it, "If the node experiences an out of memory (OOM) event prior to the kubelet being able to reclaim memory, the node depends on the oom_killer to respond." The only Kubernetes object we captured that said so was a SystemOOM event on the Node:

default     3s          Warning   SystemOOM   node/aurora-lab-worker2         System OOM encountered, victim process: python, pid: 50766

(One of three lines. It appeared on all three kind nodes because they share one kernel; expect it on one node in a real cluster.)

5. Read the containerd log on the node. This is the only record we found that survives pod deletion and names the kill:

journalctl -u containerd --no-pager | grep <container-id>

Why does kubectl delete or a rollout give exit code 137?

When a pod stops, the kubelet has the runtime send SIGTERM and wait. The pod lifecycle docs say the default "terminationGracePeriodSeconds setting is 30 seconds" and "When the grace period expires, if there is still any container running in the Pod, the kubelet triggers forcible shutdown." That forced stop is the 137.

We deleted ten pods at once, each with terminationGracePeriodSeconds: 10 and a 64Mi limit, and held them with a finalizer so their status could be read. stop_seconds is finishedAt, which has one-second resolution, minus the time of the delete, so small negatives are rounding.

case exit reason deletionTimestamp finishedAt stop_seconds
exec-handled 0 Completed 2026-11-05T22:15:52Z 2026-11-05T22:15:51Z -0.8
handled 0 Completed 2026-11-05T22:15:52Z 2026-11-05T22:15:52Z 0.2
no-handler 137 Error 2026-11-05T22:16:02Z 2026-11-05T22:16:02Z 10.2
prestop-long 0 Completed 2026-11-05T22:16:02Z 2026-11-05T22:16:02Z 10.2
prestop-slow 137 Error 2026-11-05T22:16:04Z 2026-11-05T22:16:04Z 12.2
sh-single 0 Completed 2026-11-05T22:15:52Z 2026-11-05T22:15:52Z 0.2
shared-pidns 143 Error 2026-11-05T22:15:53Z 2026-11-05T22:15:52Z 0.2
slow-drain 137 Error 2026-11-05T22:16:03Z 2026-11-05T22:16:02Z 10.2
trap-ignore 137 Error 2026-11-05T22:16:03Z 2026-11-05T22:16:02Z 10.2
wrapper-handled 137 Error 2026-11-05T22:16:03Z 2026-11-05T22:16:02Z 10.2
CaseWhat it runsResultWhy
handledPython with a SIGTERM handler0, under 1 sThe baseline
no-handlerPython with no handler, as PID 1137 at 10 sPID 1 ignores signals it has no handler for
trap-ignoreShell that traps SIGTERM and keeps looping137 at 10 sThe log shows it got the signal and carried on
wrapper-handledsh -c 'python app.py; echo done', app has a handler137 at 10 sThe shell is PID 1 and never forwards SIGTERM
sh-singlesh -c 'python app.py', same app0, under 1 sbusybox ash replaced itself with the command, so the app got SIGTERM
exec-handledsh -c 'exec python app.py'0, under 1 sexec makes the app PID 1
shared-pidnsno-handler with shareProcessNamespace: true143, under 1 sThe app is no longer PID 1, so the default action applies
slow-drainHandler that needs 30 s137 at 10 sLog shows got SIGTERM, draining for 30 s and no more
prestop-longHandler, plus a 60 s preStop0 at 10 sSIGTERM came when the grace period ended, app exited at once
prestop-slowSame, handler needs 5 s137 at 12 sOnly the 2 s extension was left to drain in

The case to remember is no-handler. Nothing in that program ignores SIGTERM on purpose. The pid_namespaces man page states the rule: "Only signals for which the "init" process has established a signal handler can be sent to the "init" process by other members of the PID namespace." The same goes for a process in an ancestor namespace, except that "SIGKILL or SIGSTOP are treated exceptionally: these signals are forcibly delivered when sent from an ancestor PID namespace." So the same Python script that dies instantly on your laptop sits through SIGTERM in a container. Its only log line was up.

The rule also explains a test of ours: kubectl exec into a pod and SIGKILL PID 1 from inside, and nothing happens. Python printed sent, and the restart count stayed 0. The same signal from the node killed it.

The prestop rows match the docs, which say that "If the preStop hook is still running after the grace period expires, the kubelet requests a small, one-off grace period extension of 2 seconds." The hook did not hold SIGTERM back past the grace period, and the only trace was a FailedPreStopHook warning on the pod.

How do you see the exit code of a deleted pod?

Normally you cannot. After a plain delete the status is gone with the object, and the event looks the same for a clean stop and a forced one:

$ time kubectl -n exit137 delete pod plain-delete
pod "plain-delete" deleted from exit137 namespace

real	0m10.525s
...
$ kubectl -n exit137 get pod plain-delete
Error from server (NotFound): pods "plain-delete" not found
...
13s         Normal   Killing     pod/plain-delete   Stopping container app

(Trimmed where marked.) The hint is the time: a delete or rollout that takes exactly the grace period for each pod. It is only a hint, because prestop-long also took 10 s and exited 0. At kind's default log level, the kubelet log had no line about the stop. Three things did work:

The containerd log on the node, where a forced stop has a Kill container line that a clean stop does not (journal prefix removed):

time="2026-11-05T22:16:10.693943859Z" level=info msg="Stop container \"f71b93589fd641bab2654f938f34ebbb834f32bd8c2e376ddd2020c409dc4855\" with signal terminated"
time="2026-11-05T22:16:20.703813235Z" level=info msg="Kill container \"f71b93589fd641bab2654f938f34ebbb834f32bd8c2e376ddd2020c409dc4855\""

A watch started before the delete, which catches the last status. Note the .object in the path, needed with --output-watch-events:

kubectl get pod <pod> -w --output-watch-events -o jsonpath='{.type} {.object.status.phase} del={.object.metadata.deletionTimestamp} {.object.status.containerStatuses[0].state}{"\n"}'
MODIFIED Failed del=2026-11-05T22:16:20Z {"terminated":{"containerID":"containerd://f71b93589fd641bab2654f938f34ebbb834f32bd8c2e376ddd2020c409dc4855","exitCode":137,"finishedAt":"2026-11-05T22:16:20Z","reason":"Error","startedAt":"2026-11-05T22:14:54Z"}}

And a finalizer on a test pod, as we did for the table above. Use it only on a pod you created to test with: a finalizer you forget to remove leaves the pod Terminating forever. To release it:

kubectl patch pod <pod> --type merge -p '{"metadata":{"finalizers":null}}'

What about 137 with no signal from Kubernetes at all?

Two more cases recorded the same fields, with no Killing event and all-zero memory.events:

host-kill	1	Error	137	2026-11-05T22:14:54Z	2026-11-05T22:16:27Z
plain-exit	3	Error	137	2026-11-05T22:15:17Z	2026-11-05T22:15:22Z

host-kill is a kill -9 of the container's process from the node. plain-exit is sh -c 'echo up; sleep 5; exit 137', with no signal involved. Kubernetes gave us no way to tell these two apart. If you land here, read the entrypoint for a wrapper that passes on a child's status, then look at what runs on the node with permission to kill: security agents, OOM daemons, cron jobs. A steady run time before each exit points at the program, as with plain-exit's 5 seconds.

Docker exit code 137

docker inspect holds the same split, and docker events is better than anything Kubernetes offers, because it records the signals.

docker inspect <container> --format '{{json .State}}'
docker events --since 1h --filter container=<container> --format '{{.Action}} signal={{index .Actor.Attributes "signal"}} exitCode={{index .Actor.Attributes "exitCode"}}'

Kernel OOM kill under --memory 128m --memory-swap 128m (events shown from after start, here and in the next case):

{"Status":"exited","Running":false,"Paused":false,"Restarting":false,"OOMKilled":true,"Dead":false,"Pid":0,"ExitCode":137,"Error":"","StartedAt":"2026-11-05T22:17:42.897005963Z","FinishedAt":"2026-11-05T22:17:43.061098118Z"}
oom signal= exitCode=
die signal= exitCode=137

docker kill, same exit code, no memory involved:

{"Status":"exited","Running":false,"Paused":false,"Restarting":false,"OOMKilled":false,"Dead":false,"Pid":0,"ExitCode":137,"Error":"","StartedAt":"2026-11-05T22:17:45.230840488Z","FinishedAt":"2026-11-05T22:17:46.338846314Z"}
kill signal=9 exitCode=
die signal= exitCode=137

docker stop on Python as PID 1 with no handler, taking the full default wait, then the same process under docker run --init:

real	0m10.098s
OOMKilled=false ExitCode=137 Status=exited
kill signal=15 exitCode=
kill signal=9 exitCode=
stop signal= exitCode=
die signal= exitCode=137
real	0m0.079s
OOMKilled=false ExitCode=143 Status=exited
kill signal=15 exitCode=
stop signal= exitCode=
die signal= exitCode=143

(Each trimmed to the real line, the state and the events after start.) The docker stop reference gives the rule: "The main process inside the container will receive SIGTERM, and after a grace period, SIGKILL." The default wait on Linux is 10 seconds.

What happenedState.OOMKilledExitCodedocker events
Kernel OOM kill of the main processtrue137oom, then die exitCode=137
docker killfalse137kill signal=9
docker stop past the timeoutfalse137kill signal=15, kill signal=9
docker stop, with --initfalse143kill signal=15 only
Program ran exit 137false137die exitCode=137 only
OOM kills a child, shell exits 0true0oom, then die exitCode=0
OOM kills a child, shell passes on $?true137Not captured

Row six is worth a look. OOMKilled is true on a container that exited 0:

$ docker run --name x137-child --memory 128m --memory-swap 128m python:3.12-alpine sh -c 'cat /sys/fs/cgroup/memory.oom.group; python -c "b = b\"\\x01\" * (200 << 20)"; echo child exit $?; exit 0'
0
child exit 137
Killed
[exit 0]
OOMKilled=true ExitCode=0 Status=exited

Docker left memory.oom.group at 0, so the kernel killed only the child and the shell carried on. Kubernetes sets it to 1 (cat /sys/fs/cgroup/memory.oom.group printed 1 in our pod), so the whole container dies. Our Kubernetes version of this test recorded OOMKilled, 137, and the kernel log named the shell as well as Python:

[  854.409589] Memory cgroup out of memory: Killed process 21673 (sh) total-vm:1652kB, anon-rss:60kB, file-rss:880kB, shmem-rss:0kB, UID:0 pgtables:44kB oom_score_adj:992

The kubelet setting singleProcessOOMKill turns that off; its default is false on cgroup v2.

Compose prints app-1 exited with code 137 and gives no reason, so run docker inspect on the container.

Exit code 137 outside containers

A kernel OOM kill of a child under a shell, in a 128M cgroup on the plain host:

$ sudo systemd-run --scope -q -p MemoryMax=128M -p MemorySwapMax=0 -p OOMPolicy=continue bash -c 'python3 -c "b = b\"\\x01\" * (300 << 20)"; echo python status $?'
/usr/bin/bash: line 1: 49723 Killed                  python3 -c "b = b\"\\x01\" * (300 << 20)"
python status 137

Killed is the shell's message for SIGKILL, not proof of OOM; our kill -9 printed it too. The same kill under a systemd service says so directly in journalctl -u <unit>:

x137-demo.service: A process of this unit has been killed by the OOM killer.

(Timestamp and host prefix removed.) docker build depends on the builder. With a builder limited to 256 MiB, the same RUN step that allocates 600 MiB reported 137 only on the legacy builder (DOCKER_BUILDKIT=0). BuildKit, second below, did not show 137 at all:

The command '/bin/sh -c python -c "b = b'\x01' * (600 << 20); print('allocated')"' returned a non-zero code: 137
ERROR: failed to build: failed to solve: ResourceExhausted: process "/bin/sh -c python -c \"b = b'\\x01' * (600 << 20); print('allocated')\"" did not complete successfully: cannot allocate memory

Fix: what to change for each cause

Mutating commands below change a live workload. Roll out through your normal path, and keep the previous manifest for rollback.

CauseChangeRiskRollback
OOM kill, either kindFollow the OOMKilled runbook; a leak or a sidecar has its ownA higher limit can mask a leakRevert the limit
Bad liveness probeFix or remove the probe (liveness probe failed)Without a probe, a hung process stays upkubectl rollout undo deploy/<name>
No SIGTERM handlerAdd one that exits. This is the real fix for every no-handler caseExiting early can drop requests in flight, so finish them firstRedeploy the old image
Shell wrapperexec the app as the last line of the scriptCommands after exec never runRevert the entrypoint
Cannot change the imageDocker: docker run --init. Compose: init: true. Kubernetes: shareProcessNamespace: true gave a fast 143 in our testSharing the namespace exposes each container's /proc and files to the others in the pod, per the docs, and some apps need PID 1Remove the field
Real drain longer than the grace periodRaise terminationGracePeriodSeconds above the measured drainSlower rollouts and node drainsRevert the value
preStop eats the grace periodSet the grace period above preStop plus drainSameRevert the value
External SIGKILLFind the sender on the nodeDepends on the sendern/a

Raising terminationGracePeriodSeconds helps only the two drain rows. For a process that ignores SIGTERM it makes each stop take longer, and it still ends in 137. Raising memory does nothing for any row except the first.

The lab fix for scenario 22 was the rollback:

$ kubectl -n shop get pods -l app=worker
NAME                      READY   STATUS    RESTARTS   AGE
worker-6cf88d4b58-cl66w   1/1     Running   0          60s

Verify: what counts as fixed?

  • Restarts: the restart count does not move for longer than two of the old cycles. In the lab a cycle was 20 s, so 60 s at 0 restarts passed.
  • Stops: time kubectl delete pod <pod> on a test pod, or one replica, finishes well under the grace period. Our forced stop took 10.5 s; pods that handled SIGTERM finished in under a second.
  • Exit code: the last state after a planned stop reads 0, or 143 if the app dies on the default action. Neither should be 137.
  • Docker: time docker stop <container> no longer takes 10 s.

Prevent: an alert that separates the two

This query needs kube-state-metrics. We did not run it in the lab, which has no kube-state-metrics; the names are from its pod metrics docs, which mark the two last_terminated metrics experimental.

(
  kube_pod_container_status_last_terminated_exitcode == 137
  unless on (namespace, pod, container)
  kube_pod_container_status_last_terminated_reason{reason="OOMKilled"} == 1
)
and on (namespace, pod, container)
increase(kube_pod_container_status_restarts_total[15m]) > 0

That fires on restarts with 137 that were not recorded as OOM. It will not see stops from a delete, since the pod is gone; for those, test shutdown directly. In CI, start the image, run docker stop, and fail the build if it exits 137 or takes the full timeout. That one check catches no-handler and wrapper-handled before they reach a cluster.

Common mistakes

  • Raising the memory limit on any 137. Our worker used 3Mi of 192Mi. More memory would have changed nothing.
  • Reading memory.events inside the replacement container. It printed oom_kill 0 seconds after a real kill.
  • Trusting Killing as a sign of a forced stop. That event means the stop began. Every pod in our table got one, including the ones that exited 0 and the probe-handled control.
  • Assuming exec alone fixes it. It makes your app PID 1. Without a handler, that is exactly the no-handler case.
  • Assuming no OOMKilled means no OOM. Check oom_kill on the pod before ruling it out.
  • Assuming Killed in a shell means memory. Any SIGKILL prints it.
  • Ignoring 137 during rollouts because it stops by itself. A SIGKILL mid-request drops what the process was doing, on every deploy.

What we saw in the lab

We ran the scenario three times on fresh GitHub Actions clusters. The selftest passed each time. Every output block above is from the last run; the first two are kept in the run folder.

  • OOM reason tally: 80 of 80, 79 of 80 and 79 of 80 recorded OOMKilled, so 238 of 240, on a quiet runner. The two Error pods were one each in round 1 of the second and third runs. The kernel printed two lines per kill in five of six rounds; one round had 71 lines for 40 pods, so we would not count kills from dmesg alone.
  • We were wrong twice. We expected a long preStop to force a 137 by itself. It did not: the app got SIGTERM at 10 s and exited 0, and we added prestop-slow to find the real boundary. And our second "node OOM" run was not one: docker update --memory 0 does not clear a limit, so the node was still capped. The kernel line CONSTRAINT_MEMCG gave it away, and only the third run produced global_oom.
  • The node OOM ran on a test runner, with swap off and one pod taking 13,800 MiB. Node-pressure eviction was not reproduced in this batch; the run is on the OOMKilled page.
  • The only shell we tested is busybox ash. Do not assume sh-single behaves the same under another shell; test your image.

The Aurora, HolmesGPT and K8sGPT investigations have not been run on this scenario, so we have no result to report for any of them. The obvious trap is the exit code: the scripted alert says 137, the worker has a memory limit, and the right answer has nothing to do with memory.

How Aurora handles this

Aurora receives the alert and investigates with read-only kubectl under its default observability_only command policy, choosing the commands itself. For a 137 it would need the same evidence as this page, and reason, events and pod specs are all reachable that way. The node-level checks here (memory.events, the kernel log, the containerd log) need node access, and we have not tested how Aurora does on them. It records every tool call and its output, cites them in the report and lists suggested fixes separately; mutating commands are blocked by default, so it suggests the change and can open a remediation PR for human approval, with no auto-merge.

Related: OOMKilled, liveness probe failed, CrashLoopBackOff by exit code, memory leak, sidecar OOMKilled, paste your kubectl output into the diagnoser, and the root cause analysis guide for SREs.

Sources and verification

Questions

Other runbooks