Repository navigation
feat: detect and report container OOM kills - #10
Merged
Merged
Conversation
The pod watcher now scans container statuses (init and regular) for terminations with reason OOMKilled — both lastState (restarted containers) and current state (restartPolicy Never) — and reports each kill exactly once via a new OnOOMKill callback. The event pairs the kill with the container's declared memory limit, plus finishedAt, exit code, restart count, and the resolved workload. OOM kills arrive as pod status updates, so the watcher gains an UpdateFunc handler; deduplication is an in-memory map keyed by container and finishedAt, purged on pod deletion. Losing it on agent restart is harmless: the same kill is re-reported, never missed. Uses only the pods/status access already promised in docs/security.md §4, which names this exact detection. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First real finding signal: an OOM kill paired with the container's declared memory limit — the two facts that make the "limit too low" story.
What
internal/collector/oom.go:OOMKillevent (namespace, pod, container, resolved workload, finishedAt, exit code, restart count,memory_limit_bytes) reported via a newPodWatcher.OnOOMKillcallbacklastState.terminated(container restarted) andstate.terminated(restartPolicy: Never), for init and regular containersUpdateFunchandler — OOM kills happen after the pod appears and arrive as status updates; the pod itself is not re-reportedstatetolastStatekeeps its key), purged on pod deletion. Losing the map on agent restart re-reports the same kill — harmless, per the loss-harmless state invariantcmd/agent: logsoom kill observedat WARNScope
Uses only the
podsread access already promised in docs/security.md §4, which names this exact detection (lastState.terminated.reason == "OOMKilled") — no doc change needed.Verified
Errorcrash not reportedmemory_limit_bytes: 33554432, bare-pod workloadnonego test -race ./..., golangci-lint clean🤖 Generated with Claude Code