From 36c62f7ef4f8044937ffacda3d0d53451dd5a526 Mon Sep 17 00:00:00 2001 From: Abhisheka Date: Thu, 11 Jan 2024 09:52:32 +0000 Subject: [PATCH] Events log added --- pkg/controllers/dataexport/reconcile.go | 26 +++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/pkg/controllers/dataexport/reconcile.go b/pkg/controllers/dataexport/reconcile.go index c32c22bd2..3b0eb4bd6 100644 --- a/pkg/controllers/dataexport/reconcile.go +++ b/pkg/controllers/dataexport/reconcile.go @@ -626,18 +626,36 @@ func appendPodLogToStork(jobName string, namespace string) { numLogLines := int64(50) podDescribe, err := core.Instance().GetPodByName(pod.Name, pod.Namespace) if err != nil { - logrus.Infof("Error fetching description of job-pod[%s] :%v", pod.Name, err) + logrus.Infof("error fetching description of job-pod[%s] :%v", pod.Name, err) } - logrus.Infof("start of job-pod [%s]'s description", pod.Name) - logrus.Infof("Describe %v", podDescribe) + logrus.Infof("---") + logrus.Infof("pod describe of job [%s/%s] of namespace [%s]", pod.Name, jobName, pod.Namespace) + logrus.Infof("---") + logrus.Infof("%v", podDescribe) logrus.Infof("end of job-pod [%s]'s description", pod.Name) + logrus.Infof("---") + logrus.Infof("pod events of job [%s/%s] of namespace [%s]", pod.Name, jobName, pod.Namespace) + logrus.Infof("---") + opts := metav1.ListOptions{ + FieldSelector: "involvedObject.name=" + pod.Name, + } + events, err := core.Instance().ListEvents(namespace, opts) + if err != nil { + logrus.Infof("error to fetch events for pod[%s/%s]: %v", namespace, pod.Name, err) + } else { + logrus.Infof("%v", events) + logrus.Infof("---") + } podLog, err := core.Instance().GetPodLog(pod.Name, pod.Namespace, &corev1.PodLogOptions{TailLines: &numLogLines}) if err != nil { logrus.Infof("error fetching log of job-pod %s: %v", pod.Name, err) } else { - logrus.Infof("start of job-pod [%s]'s log...", pod.Name) + logrus.Infof("---") + logrus.Infof("pod log of job [%s/%s]", pod.Name, jobName) + logrus.Infof("---") logrus.Infof(podLog) logrus.Infof("end of job-pod [%s]'s log...", pod.Name) + logrus.Infof("---") } } }