Skip to content

fix(analyzer): skip succeeded pods to prevent false positive reports#1639

Open
octo-patch wants to merge 2 commits intok8sgpt-ai:mainfrom
octo-patch:fix/issue-1581-skip-succeeded-pods
Open

fix(analyzer): skip succeeded pods to prevent false positive reports#1639
octo-patch wants to merge 2 commits intok8sgpt-ai:mainfrom
octo-patch:fix/issue-1581-skip-succeeded-pods

Conversation

@octo-patch
Copy link
Copy Markdown

Fixes #1581

Problem

The pod analyzer incorrectly reports completed Job/CronJob pods as having issues. When a multi-container pod finishes successfully, sidecar containers are terminated by Kubernetes with non-zero exit codes (commonly 255). The analyzer was flagging these terminated sidecar containers as failures even though the pod phase was Succeeded (shown as Completed by kubectl).

Example false positive:

2. xxx/smoke-test-xxx-cloudloader-dataeditor-2-f7rl4
   Type: Pod
   Error 1: the termination reason is Error exitCode=255 container=smoke-test ...

Solution

Add an early-continue guard at the top of the pod analysis loop that skips any pod whose phase is PodSucceeded. A pod in this phase has completed its work normally; there is no value in analyzing its container states for failures.

if pod.Status.Phase == v1.PodSucceeded {
    continue
}

Testing

Added a test case "Succeeded pod with non-zero exit code container should not be reported" that creates a pod in PodSucceeded phase with a sidecar container terminated with exit code 255, and asserts that no failures are reported.

…ositives

Pods in the Succeeded phase (shown as 'Completed' by kubectl) represent
Job/CronJob pods that finished their work successfully. In multi-container
pods, sidecar containers may be forcefully terminated with non-zero exit
codes (e.g., 255) when the main container completes. The pod analyzer was
incorrectly flagging these as failures.

Add an early-continue check that skips any pod whose phase is PodSucceeded,
and add a corresponding test case to document the expected behaviour.

Fixes k8sgpt-ai#1581

Signed-off-by: octo-patch <octo-patch@github.com>
@octo-patch octo-patch requested review from a team as code owners April 20, 2026 03:33
@github-project-automation github-project-automation Bot moved this to Proposed in Backlog Apr 20, 2026
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented Apr 20, 2026

CLA Missing ID CLA Not Signed

@AlexsJones
Copy link
Copy Markdown
Member

Please sign CLA @octo-patch and t his looks good to go

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic looks spot on. CI is failing though — looks like the branch is behind. Could you rebase and check the logs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Proposed

Development

Successfully merging this pull request may close these issues.

[Question]: incorrect report successfully completed pod as issue with exit code 255

3 participants