From 90a9b78e022670edf9560f86a6e8907c533fa2b9 Mon Sep 17 00:00:00 2001 From: rcourtman Date: Thu, 18 Dec 2025 16:59:37 +0000 Subject: [PATCH] fix: correct pod/deployment filtering logic and fix test helper calls - Remove unused sets import from kubernetesagent - Fix inverted filtering logic: keep problem pods/deployments, skip healthy ones - Fix test helper calls: use slice literals instead of undefined makeNamespaceSet --- internal/kubernetesagent/agent.go | 4 ++-- internal/kubernetesagent/agent_test.go | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/internal/kubernetesagent/agent.go b/internal/kubernetesagent/agent.go index fc1028b..467a7ee 100644 --- a/internal/kubernetesagent/agent.go +++ b/internal/kubernetesagent/agent.go @@ -468,7 +468,7 @@ func (a *Agent) collectPods(ctx context.Context) ([]agentsk8s.Pod, error) { if !a.namespaceAllowed(pod.Namespace) { continue } - if !a.cfg.IncludeAllPods && isProblemPod(pod) { + if !a.cfg.IncludeAllPods && !isProblemPod(pod) { continue } @@ -600,7 +600,7 @@ func (a *Agent) collectDeployments(ctx context.Context) ([]agentsk8s.Deployment, if !a.namespaceAllowed(dep.Namespace) { continue } - if isProblemDeployment(dep) { + if !isProblemDeployment(dep) { continue } diff --git a/internal/kubernetesagent/agent_test.go b/internal/kubernetesagent/agent_test.go index 7931e79..6dc40a2 100644 --- a/internal/kubernetesagent/agent_test.go +++ b/internal/kubernetesagent/agent_test.go @@ -62,8 +62,8 @@ users: func TestNamespaceAllowed_IncludeExclude(t *testing.T) { a := &Agent{ - includeNamespaces: makeNamespaceSet([]string{"a", "b"}), - excludeNamespaces: makeNamespaceSet([]string{"b"}), + includeNamespaces: []string{"a", "b"}, + excludeNamespaces: []string{"b"}, } if !a.namespaceAllowed("a") { @@ -122,9 +122,9 @@ func TestCollectPods_FiltersProblemsAndSorts(t *testing.T) { MaxPods: 2, IncludeAllPods: false, }, - kubeClient: clientset, - includeNamespaces: makeNamespaceSet(nil), - excludeNamespaces: makeNamespaceSet(nil), + kubeClient: clientset, + includeNamespaces: nil, + excludeNamespaces: nil, } pods, err := a.collectPods(context.Background()) @@ -165,10 +165,10 @@ func TestCollectDeployments_FiltersProblems(t *testing.T) { ) a := &Agent{ - cfg: Config{IncludeAllPods: false}, - kubeClient: clientset, - includeNamespaces: makeNamespaceSet(nil), - excludeNamespaces: makeNamespaceSet(nil), + cfg: Config{IncludeAllPods: false}, + kubeClient: clientset, + includeNamespaces: nil, + excludeNamespaces: nil, } deps, err := a.collectDeployments(context.Background())