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
This commit is contained in:
parent
1e955255a6
commit
90a9b78e02
2 changed files with 11 additions and 11 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
|
|
|
|||
Loading…
Reference in a new issue