Skip to content

Commit

Permalink
When searching for PODs ignore the Completed or Failed (#5)
Browse files Browse the repository at this point in the history
Co-authored-by: Matteo Gazzadi Poggioli <matteo.gazzadi@tetrapak.com>
  • Loading branch information
matteogazzadi and Matteo Gazzadi Poggioli committed Mar 29, 2024
1 parent 92285fd commit 772844c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions pkg/helpers/k8shelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,20 @@ func GetPodsByNamespace(clientset *kubernetes.Clientset, ctx context.Context, na

if err != nil {
log.Fatal(err)
} else {
podChan <- pods.Items
return
}

// Filter out completed Pods
var filteredPods []v1.Pod
for _, pod := range pods.Items {

// Filter out pod in status Succeeded or Failed.
if pod.Status.Phase != v1.PodSucceeded && pod.Status.Phase != v1.PodFailed {
filteredPods = append(filteredPods, pod)
}
}

podChan <- filteredPods
}

// Get All Namespaces in the cluster
Expand Down

0 comments on commit 772844c

Please sign in to comment.