mirror of
https://github.com/k8sgpt-ai/k8sgpt.git
synced 2025-09-01 15:28:12 +00:00
feat: add event failure handling in service analyzer (#1132)
Signed-off-by: magicsong <songxuetao@bytedance.com> Co-authored-by: magicsong <songxuetao@bytedance.com> Co-authored-by: Alex Jones <alexsimonjones@gmail.com> Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
This commit is contained in:
@@ -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 {
|
if len(failures) > 0 {
|
||||||
preAnalysis[fmt.Sprintf("%s/%s", ep.Namespace, ep.Name)] = common.PreAnalysis{
|
preAnalysis[fmt.Sprintf("%s/%s", ep.Namespace, ep.Name)] = common.PreAnalysis{
|
||||||
Endpoint: ep,
|
Endpoint: ep,
|
||||||
|
Reference in New Issue
Block a user