Skip to content

Commit

Permalink
Use a better util
Browse files Browse the repository at this point in the history
Signed-off-by: Laura Lorenz <[email protected]>

Kubernetes-commit: 8e7b2af712a79db423b7bfdf2a7bf35f75542c13
  • Loading branch information
lauralorenz authored and k8s-publishing-bot committed Nov 12, 2024
1 parent 1811eba commit 133d258
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions pkg/util/podutils/podutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,7 @@ func podReadyTime(pod *corev1.Pod) *metav1.Time {
return &metav1.Time{}
}

// MaxContainerRestarts iterates through all the normal containers and sidecar
// containers in a Pod object and reports the highest restart count observed per
// category.
func MaxContainerRestarts(pod *corev1.Pod) (regularRestarts, sidecarRestarts int) {
func maxContainerRestarts(pod *corev1.Pod) (regularRestarts, sidecarRestarts int) {
for _, c := range pod.Status.ContainerStatuses {
regularRestarts = max(regularRestarts, int(c.RestartCount))
}
Expand All @@ -217,8 +214,8 @@ func MaxContainerRestarts(pod *corev1.Pod) (regularRestarts, sidecarRestarts int
// false: pj has a higher container restart count.
// nil: Both have the same container restart count.
func compareMaxContainerRestarts(pi *corev1.Pod, pj *corev1.Pod) *bool {
regularRestartsI, sidecarRestartsI := MaxContainerRestarts(pi)
regularRestartsJ, sidecarRestartsJ := MaxContainerRestarts(pj)
regularRestartsI, sidecarRestartsI := maxContainerRestarts(pi)
regularRestartsJ, sidecarRestartsJ := maxContainerRestarts(pj)
if regularRestartsI != regularRestartsJ {
res := regularRestartsI > regularRestartsJ
return &res
Expand Down

0 comments on commit 133d258

Please sign in to comment.