Skip to content

Commit 58d69bf

Browse files
committed
skip failed pods (any reason); fix empty start time panic
1 parent b683c74 commit 58d69bf

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

internal/controller/controller.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,13 @@ func (s *scanner) DeletePod(obj interface{}) {
4848
"namespace": pod.Namespace,
4949
"name": pod.Name,
5050
}).Debug("pod deleted")
51-
// skip "Failed" pods with UnsupportedPodSpec reason (e.g. DaemonSet pods on Fargate)
52-
if pod.Status.Phase == v1.PodFailed && pod.Status.Reason == "UnsupportedPodSpec" {
51+
// skip "Failed" pods (e.g. DaemonSet pods on Fargate)
52+
if pod.Status.Phase == v1.PodFailed {
5353
s.log.WithFields(logrus.Fields{
5454
"namespace": pod.Namespace,
5555
"name": pod.Name,
56-
}).Debug("skipped failed pod with UnsupportedPodSpec")
56+
"reason": pod.Status.Reason,
57+
}).Debug("skipped failed pod ")
5758
return
5859
}
5960
// get the node info from the cache

internal/usage/record.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,13 @@ func GetPodInfo(log *logrus.Entry, pod *v1.Pod, beginTime, endTime time.Time, no
214214
// set pod measured time
215215
record.BeginTime = beginTime
216216
record.EndTime = endTime
217-
// copy pod start time
218-
record.StartTime = pod.Status.StartTime.Time
219-
// update pod begin time to the earliest pod start time
220-
if record.StartTime.After(beginTime) {
221-
record.BeginTime = record.StartTime
217+
// copy pod start time if available
218+
if pod.Status.StartTime != nil {
219+
record.StartTime = pod.Status.StartTime.Time
220+
// update pod begin time to the earliest pod start time
221+
if record.StartTime.After(beginTime) {
222+
record.BeginTime = record.StartTime
223+
}
222224
}
223225
if node != nil {
224226
// patch fargate node info from pod annotations, if needed

0 commit comments

Comments
 (0)