fix(analyzer): skip succeeded pods to prevent false positive reports#1639
Open
octo-patch wants to merge 2 commits intok8sgpt-ai:mainfrom
Open
fix(analyzer): skip succeeded pods to prevent false positive reports#1639octo-patch wants to merge 2 commits intok8sgpt-ai:mainfrom
octo-patch wants to merge 2 commits intok8sgpt-ai:mainfrom
Conversation
…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>
|
Member
|
Please sign CLA @octo-patch and t his looks good to go |
Contributor
three-foxes-in-a-trenchcoat
left a comment
There was a problem hiding this comment.
Logic looks spot on. CI is failing though — looks like the branch is behind. Could you rebase and check the logs?
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.
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 asCompletedby kubectl).Example false positive:
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.Testing
Added a test case
"Succeeded pod with non-zero exit code container should not be reported"that creates a pod inPodSucceededphase with a sidecar container terminated with exit code 255, and asserts that no failures are reported.