diff --git a/internal/controller/controller.go b/internal/controller/controller.go index bd7d70d..a482a9a 100644 --- a/internal/controller/controller.go +++ b/internal/controller/controller.go @@ -48,12 +48,13 @@ func (s *scanner) DeletePod(obj interface{}) { "namespace": pod.Namespace, "name": pod.Name, }).Debug("pod deleted") - // skip "Failed" pods with UnsupportedPodSpec reason (e.g. DaemonSet pods on Fargate) - if pod.Status.Phase == v1.PodFailed && pod.Status.Reason == "UnsupportedPodSpec" { + // skip "Failed" pods (e.g. DaemonSet pods on Fargate) + if pod.Status.Phase == v1.PodFailed { s.log.WithFields(logrus.Fields{ "namespace": pod.Namespace, "name": pod.Name, - }).Debug("skipped failed pod with UnsupportedPodSpec") + "reason": pod.Status.Reason, + }).Debug("skipped failed pod ") return } // get the node info from the cache diff --git a/internal/usage/record.go b/internal/usage/record.go index d03ceff..9c0c303 100644 --- a/internal/usage/record.go +++ b/internal/usage/record.go @@ -214,11 +214,13 @@ func GetPodInfo(log *logrus.Entry, pod *v1.Pod, beginTime, endTime time.Time, no // set pod measured time record.BeginTime = beginTime record.EndTime = endTime - // copy pod start time - record.StartTime = pod.Status.StartTime.Time - // update pod begin time to the earliest pod start time - if record.StartTime.After(beginTime) { - record.BeginTime = record.StartTime + // copy pod start time if available + if pod.Status.StartTime != nil { + record.StartTime = pod.Status.StartTime.Time + // update pod begin time to the earliest pod start time + if record.StartTime.After(beginTime) { + record.BeginTime = record.StartTime + } } if node != nil { // patch fargate node info from pod annotations, if needed