Skip to content

Commit 442c9cd

Browse files
Update pkg/health/health_pod.go
improve code readability Co-authored-by: sivchari <shibuuuu5@gmail.com> Signed-off-by: Roelof Kuijpers <roelof.kuijpers@energyessentials.nl>
1 parent 4f030bf commit 442c9cd

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

pkg/health/health_pod.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,12 @@ func getCorev1PodHealth(pod *corev1.Pod) (*HealthStatus, error) {
122122
Message: pod.Status.Message,
123123
}, nil
124124
}
125-
if _, hook := pod.Annotations[AnnotationIgnoreRestartPolicy]; hook {
125+
policy := pod.Spec.RestartPolicy
126+
if _, ok := pod.Annotations[AnnotationIgnoreRestartPolicy]; ok || policy == corev1.RestartPolicyAlways {
126127
return getHealthStatus(pod)
127-
} else {
128-
switch pod.Spec.RestartPolicy {
129-
case corev1.RestartPolicyAlways:
130-
return getHealthStatus(pod)
131-
case corev1.RestartPolicyOnFailure, corev1.RestartPolicyNever:
128+
}
129+
130+
if policy == corev1.RestartPolicyOnFailure || policy == corev1.RestartPolicyNever {
132131
// Most pods set with a restart policy of OnFailure or Never, have a finite life.
133132
// These pods are typically resource hooks. Thus, we consider these as Progressing
134133
// instead of healthy. If this is unwanted, e.g., when the pod is managed by an

0 commit comments

Comments
 (0)