Skip to content

Commit

Permalink
feat: added FailedMount event reason to get the failure (#883)
Browse files Browse the repository at this point in the history
Signed-off-by: lwan3 <lili_wan@intuit.com>
Co-authored-by: lwan3 <lili_wan@intuit.com>
  • Loading branch information
lili-wan and lwan3 committed Feb 1, 2024
1 parent 60853fe commit 78126b2
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions pkg/analyzer/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (PodAnalyzer) Analyze(a common.Analyzer) ([]common.Result, error) {
if err != nil || evt == nil {
continue
}
if evt.Reason == "FailedCreatePodSandBox" && evt.Message != "" {
if isEvtErrorReason(evt.Reason) && evt.Message != "" {
failures = append(failures, common.Failure{
Text: evt.Message,
Sensitive: []common.Sensitive{},
Expand Down Expand Up @@ -137,7 +137,21 @@ func (PodAnalyzer) Analyze(a common.Analyzer) ([]common.Result, error) {

func isErrorReason(reason string) bool {
failureReasons := []string{
"CrashLoopBackOff", "ImagePullBackOff", "CreateContainerConfigError", "PreCreateHookError", "CreateContainerError", "PreStartHookError", "RunContainerError", "ImageInspectError", "ErrImagePull", "ErrImageNeverPull", "InvalidImageName",
"CrashLoopBackOff", "ImagePullBackOff", "CreateContainerConfigError", "PreCreateHookError", "CreateContainerError",
"PreStartHookError", "RunContainerError", "ImageInspectError", "ErrImagePull", "ErrImageNeverPull", "InvalidImageName",
}

for _, r := range failureReasons {
if r == reason {
return true
}
}
return false
}

func isEvtErrorReason(reason string) bool {
failureReasons := []string{
"FailedCreatePodSandBox", "FailedMount",
}

for _, r := range failureReasons {
Expand Down

0 comments on commit 78126b2

Please sign in to comment.