Skip to content

Failure reasons and agent loss

When a Job gets the condition Failed=True, the agent reports a reason and a message. The alert shows them, so you see why a CronJob failed, not just that it did.

Examples of reasons: OOMKilled, Error, ImagePullBackOff, ErrImagePull, CrashLoopBackOff, CreateContainerConfigError, Unschedulable, Evicted, BackoffLimitExceeded, DeadlineExceeded.

How it is decided:

  1. The agent reads the reason of the Job’s Failed condition (for example DeadlineExceeded).
  2. It also inspects the container states of the Job’s pods: the terminated reason and exit code (OOMKilled, Error) and the waiting reason (ImagePullBackOff, ErrImagePull, CrashLoopBackOff). If several containers are abnormal, OOMKilled wins, then other terminated states, then waiting states.
  3. BackoffLimitExceeded only says that retries ran out, not why. When container information is known, the container reason (for example OOMKilled) is reported instead. Any other Job condition reason, such as DeadlineExceeded, stays the reason and the container details are added to the message.

Message format, with what makes it useful:

container backup terminated: OOMKilled (exit code 137, memory limit 256Mi)
container job terminated: Error (exit code 127, command not found)
container app waiting: CreateContainerConfigError (secret "db-credentials" not found)
container app waiting: ImagePullBackOff (Back-off pulling image "registry.example/app:2")
pod unschedulable: 0/3 nodes are available: 3 Insufficient memory.
pod evicted: The node was low on resource: memory.
You see It usually means
OOMKilled with a memory limit The container used more memory than its limit. Raise resources.limits.memory or reduce the use
exit code 126 / 127 The command cannot be executed / was not found in the image
exit code 137 / 139 / 143 Killed with SIGKILL (often by the node) / segmentation fault / stopped with SIGTERM
CreateContainerConfigError A Secret or ConfigMap the pod needs does not exist (the message names it)
ImagePullBackOff, ErrImagePull The image name or tag is wrong, or the registry needs credentials
Unschedulable No node fits the pod (memory, CPU, taints, affinity). The message lists why
Evicted The node ran short of a resource and removed the pod

Other exit codes belong to your program. The agent does not guess what they mean. A container problem is reported before a pod level problem, and OOMKilled before everything else.

Pods are often deleted when a Job ends (ttlSecondsAfterFinished). The agent therefore remembers the last abnormal container state per Job while it watches the pods, and uses it when the Job fails. The memory is bounded (5000 Jobs, 20 pods per Job).

The agent sends a heartbeat every 60 seconds. If CronBeat has not heard from an agent for 3 minutes (checked every 30 seconds), the agent is marked lost:

  • One agent_lost incident is opened for the cluster, and the notification goes to all channels of your project. You get one alert, not one per CronJob.
  • The monitors of that cluster cannot go down while the agent is lost, because without the agent CronBeat cannot know whether the Jobs ran. They can still become late.
  • When the agent reports again, the incident closes with a recovery message, the monitors of the cluster are checked again and their deadlines are recalculated from that moment, so there is no instant false alarm.

Revoking an agent key in the app also ends a lost incident for that agent.

If you see an agent_lost alert, check the Deployment in your cluster (kubectl -n cronbeat-agent get pods), its logs, and whether the cluster can reach the CronBeat API over HTTPS. A 401 in the logs means the key was revoked or is wrong.