KubeErrors

Exit code 128: An invalid exit argument, or the base of the signal-encoded range

128 is the base from which signal-terminated exit codes are counted: a process killed by signal N reports 128 + N. A literal 128 is rare and usually means a program called exit with an out-of-range value.

Applies to: All Kubernetes versions, Linux nodes

What it means

When a process is terminated by a signal, the shell and the container runtime report its status as 128 plus the signal number — which is how 137 (128 + SIGKILL) and 143 (128 + SIGTERM) get their values. A bare 128 is not itself a signal termination, since there is no signal 0 in this sense. It normally appears when a program passes an invalid argument to exit, or when a shell script exits with a value outside 0–255 and the result wraps. Practically, the useful thing to know about 128 is the arithmetic: any container exit code above 128 should be read by subtracting 128 and looking up the signal.

Most common causes

How to diagnose it

  1. Read the container's termination reason as well as the code: kubectl describe pod POD under Last State. If a signal was involved, the reason usually names it.
  2. If the code is above 128, subtract 128 and look up the signal number in signal(7) — 9 is SIGKILL, 15 is SIGTERM, 11 is SIGSEGV, 6 is SIGABRT.
  3. Check any wrapper script for how it propagates the status of the process it launches.
  4. Read the logs for the real error, which is usually more informative than the code.

How to fix it

  1. Make wrapper scripts exec the real process so its exit status is reported directly rather than translated.
  2. Ensure any explicit exit call uses a value between 0 and 255.
  3. Treat the arithmetic as the diagnosis: fix whatever caused the signal, not the code.

Notes

Because exit statuses are 8 bits, a program returning 256 reports 0 — a success that never happened. This is a real source of silently passing batch jobs and is worth checking in any script that computes an exit status.

Related

Sources

Pages on this site are written with AI assistance from the primary sources listed on each page, then checked against those sources before publishing.