Skip to content

Commit

Permalink
Do not display pending pods (#242)
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Paskal <paskal.maksim@gmail.com>
  • Loading branch information
maksim-paskal authored Nov 4, 2024
1 parent a20b6f8 commit c23303c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/api/GetPodsInfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,21 @@ import (
"context"
"fmt"
"strconv"
"time"

"github.com/maksim-paskal/kubernetes-manager/pkg/telemetry"
"github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
)

const podPendingDuration = 2 * time.Minute

type PodsInfo struct {
PodsTotal int64
PodsReady int64
PodsFailed int64
PodsFailedName []string
PodsPendingName []string
cpuRequests float64
memoryRequests float64
storageRequests float64
Expand Down Expand Up @@ -84,6 +88,13 @@ func (e *Environment) GetPodsInfo(ctx context.Context) (*PodsInfo, error) {
if isPodReady {
result.PodsReady++
} else {
// check if pod is still starting
if time.Since(pod.CreationTimestamp.Time) < podPendingDuration {
result.PodsPendingName = append(result.PodsPendingName, pod.Name)

continue
}

result.PodsFailed++

if podReason == string(corev1.PodRunning) {
Expand Down

0 comments on commit c23303c

Please sign in to comment.