Skip to content

Commit

Permalink
Clearer image pull test and utils
Browse files Browse the repository at this point in the history
Signed-off-by: Laura Lorenz <lauralorenz@google.com>

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

func maxContainerRestarts(pod *corev1.Pod) (regularRestarts, sidecarRestarts int) {
// 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) {
for _, c := range pod.Status.ContainerStatuses {
regularRestarts = max(regularRestarts, int(c.RestartCount))
}
Expand All @@ -214,8 +217,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 1811eba

Please sign in to comment.