From bb066912a802af3e5286b5cbba29cf38d34d1cdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=90=AF=E8=88=AA?= <101104760+ZhangSetSail@users.noreply.github.com> Date: Fri, 27 Dec 2024 09:23:45 +0800 Subject: [PATCH] fix: upload some warn conditions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张启航 <101104760+ZhangSetSail@users.noreply.github.com> --- worker/master/podevent/podevent.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/worker/master/podevent/podevent.go b/worker/master/podevent/podevent.go index 494475d72..49e7a5ff3 100644 --- a/worker/master/podevent/podevent.go +++ b/worker/master/podevent/podevent.go @@ -163,12 +163,15 @@ func recordUpdateEvent(clientset kubernetes.Interface, pod *corev1.Pod, f determ } // running time - var rtime time.Time + var rtime metav1.Time for _, condition := range pod.Status.Conditions { if condition.Type != corev1.PodReady || condition.Status != corev1.ConditionTrue { continue } - rtime = condition.LastTransitionTime.Time + if condition.LastTransitionTime.IsZero() { + continue + } + rtime = condition.LastTransitionTime } // the container state of the pod in the PodStatus_Running must be running @@ -178,7 +181,7 @@ func recordUpdateEvent(clientset kubernetes.Interface, pod *corev1.Pod, f determ logrus.Debugf("Service id: %s; %s.", serviceID, msg) loggerOpt := event.GetLoggerOption("failure") - if !rtime.IsZero() && time.Now().Sub(rtime) > 2*time.Minute { + if !rtime.IsZero() && time.Now().Sub(rtime.Time) > 2*time.Minute { evt.FinalStatus = model.EventFinalStatusEmptyComplete.String() if err := db.GetManager().ServiceEventDao().UpdateModel(evt); err != nil { logrus.Warningf("event id: %s; failed to update service event: %v", evt.EventID, err)