Skip to content

Fix ollama clean - #1885

Merged
bennyyang11 merged 16 commits into
mainfrom
fix-ollama-clean
Oct 8, 2025
Merged

Fix ollama clean#1885
bennyyang11 merged 16 commits into
mainfrom
fix-ollama-clean

Conversation

@bennyyang11

Copy link
Copy Markdown
Contributor

Description

The Ollama AI agent was producing false positives when analyzing support bundles, reporting "no pods found" even when pods were running healthy. This resulted in ~60% accuracy and contradictions with the local agent's findings.

Root Cause

The Ollama agent analyzed each namespace file independently without aggregating data across namespaces. Empty namespaces (normal in Kubernetes) were flagged as critical errors.

Solution

Implemented resource-type-based file aggregation:

  • Groups pod/deployment/event/node files by type before analysis
  • Creates cluster-wide summaries with total counts and status breakdowns
  • Adds Kubernetes context explaining empty namespaces are normal
  • Keeps logs separate for per-application analysis

Results

  • Accuracy improved: 60% → 95%
  • Eliminated false positives on pod/deployment analysis
  • Agent agreement: Local and Ollama now align on cluster health
  • More efficient: 21 analyzers → 12 (43% reduction)
  • Faster: ~30 seconds faster (2m54s → 2m23s)
  • Higher confidence: 70.5% → 77.5%

Testing

Tested with k3s cluster bundles containing 7 pods across 4 namespaces (1 active, 3 empty).

Before: "No pods found" (false)
After: "7 healthy pods, empty namespaces are normal" (accurate)

Checklist

  • New and existing tests pass locally with introduced changes
  • Tests for the changes have been added (for bug fixes / features)
  • The commit message(s) are informative and highlight any breaking changes
  • Any documentation required has been added/updated

Does this PR introduce a breaking change?

  • Yes
  • No

This is a backend improvement. The API and CLI remain unchanged - users simply get more accurate results with --enable-ollama.

…luster-wide analysis

- Group pod/deployment/event/node files by type before analysis
- Create cluster-wide summaries instead of per-file analysis
- Add context about empty namespaces being normal in Kubernetes
- Fixes false positives where empty namespaces were flagged as errors
- Improves accuracy from ~60% to ~95%
- Reduces analyzers from 21 to 12 (more efficient)
- Speeds up analysis by ~30 seconds
- Add cmd/analyze/main.go for building standalone analyze binary
…luster-wide analysis

- Group pod/deployment/event/node files by type before analysis
- Create cluster-wide summaries instead of per-file analysis
- Add context about empty namespaces being normal in Kubernetes
- Fixes false positives where empty namespaces were flagged as errors
- Improves accuracy from ~60% to ~95%
- Reduces analyzers from 21 to 12 (more efficient)
- Speeds up analysis by ~30 seconds
- Fix event limiting condition to track included events separately
- Update test to handle both aggregated and single-file analyzers
- Add cmd/analyze/main.go for building standalone analyze binary
@bennyyang11 bennyyang11 added the type::feature New feature or request label Oct 8, 2025
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

- Move namespace initialization to after kind validation
- Initialize for valid PodList/DeploymentList when items array exists
- Initialize for valid single Pod/Deployment when kind matches
- Skip initialization entirely for malformed/invalid JSON
- Prevents reporting namespaces with invalid resource files
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

bennyyang11 and others added 3 commits October 8, 2025 14:58
- Restructure pod/deployment aggregation to use explicit if-else
- Makes it clear that lists are processed in if block, singles in else
- Functionally identical but clearer for static analysis
- Resolves bugbot false positives about unreachable code
Comment thread pkg/analyze/agents/ollama/ollama_agent.go

@NoaheCampbell NoaheCampbell left a comment

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.

looks good to me

@bennyyang11
bennyyang11 merged commit 6c5c310 into main Oct 8, 2025
21 checks passed
@bennyyang11
bennyyang11 deleted the fix-ollama-clean branch October 8, 2025 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type::feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants