From 7919d35880995ab3fb9ea0bf8fd778cbb9de87ea Mon Sep 17 00:00:00 2001 From: Xuetao Song <625448253@qq.com> Date: Tue, 13 Aug 2024 13:36:15 +0800 Subject: [PATCH] feat: add event failure handling in service analyzer (#1132) Signed-off-by: magicsong Co-authored-by: magicsong Co-authored-by: Alex Jones Signed-off-by: AlexsJones --- pkg/analyzer/service.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/pkg/analyzer/service.go b/pkg/analyzer/service.go index 0c18d71ddf..3466826b5d 100644 --- a/pkg/analyzer/service.go +++ b/pkg/analyzer/service.go @@ -111,7 +111,22 @@ func (ServiceAnalyzer) Analyze(a common.Analyzer) ([]common.Result, error) { }) } } - + // fetch event + events, err := a.Client.GetClient().CoreV1().Events(a.Namespace).List(a.Context, + metav1.ListOptions{ + FieldSelector: "involvedObject.name=" + ep.Name, + }) + + if err != nil { + return nil, err + } + for _, event := range events.Items { + if event.Type != "Normal" { + failures = append(failures, common.Failure{ + Text: fmt.Sprintf("Service %s/%s has event %s", ep.Namespace, ep.Name, event.Message), + }) + } + } if len(failures) > 0 { preAnalysis[fmt.Sprintf("%s/%s", ep.Namespace, ep.Name)] = common.PreAnalysis{ Endpoint: ep,