INNER CODE UNIT · Go
shouldIgnoreRestartsWithExitCodeZero
airwallex/k8s-pod-restart-info-collector · helpers.go:97
func shouldIgnoreRestartsWithExitCodeZero(status v1.ContainerStatus) bool {
if os.Getenv("IGNORE_RESTARTS_WITH_EXIT_CODE_ZERO") != "true" {
return false
}
if status.LastTerminationState.Terminated != nil && status.LastTerminationState.Terminated.ExitCode == 0 {
return true
}
return false
}
func getIgnoreRestartCount() int {
ignoreRestartCount, err := strconv.Atoi(os.Getenv("IGNORE_RESTART_COUNT"))
if err != nil {
ignoreRestartCount = 30
klog.Warningf("Environment variable IGNORE_RESTART_COUNT is not set, default: %d\n", ignoreRestartCount)
}
return ignoreRestartCount