Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix crash when run sonobuoy in serverless kubernetes cluster #1108

Merged
merged 2 commits into from
Apr 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/plugin/driver/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func IsPodFailing(pod *v1.Pod) (bool, string) {
}

// Check if it can't fetch its image within the maximum wait time
if waiting := cstatus.State.Waiting; waiting != nil {
if waiting := cstatus.State.Waiting; waiting != nil && pod.Status.StartTime != nil {
elapsedPodTime := time.Now().Sub(pod.Status.StartTime.Time)
if elapsedPodTime > maxWaitForImageTime && (waiting.Reason == "ImagePullBackOff" || waiting.Reason == "ErrImagePull") {
errstr := fmt.Sprintf("Failed to pull image for container %v within %v. Container is in state %v", cstatus.Name, maxWaitForImageTime, waiting.Reason)
Expand Down
15 changes: 15 additions & 0 deletions pkg/plugin/driver/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,21 @@ func TestPodFailing(t *testing.T) {
}
return p
}),
}, {
desc: "Does not panic if StartTime is nil when container status is waiting",
expectFailing: false,
expectMsg: "",
pod: fromGoodPod(func(p *corev1.Pod) *corev1.Pod {
p.Status.StartTime = nil
p.Status.ContainerStatuses = []corev1.ContainerStatus{
{State: corev1.ContainerState{
Waiting: &corev1.ContainerStateWaiting{
Reason: "ImagePullBackOff",
},
}},
}
return p
}),
}, {
desc: "ImagePullBackOff is not considered a failure if elapsed time within wait window",
expectFailing: false,
Expand Down