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

Include Image name in image pull error message #1718

Merged
merged 3 commits into from
May 27, 2022
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 @@ -70,7 +70,7 @@ func IsPodFailing(pod *v1.Pod) (bool, string) {
if waiting := cstatus.State.Waiting; waiting != nil && pod.Status.StartTime != nil {
elapsedPodTime := time.Since(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)
errstr := fmt.Sprintf("Failed to pull image %v for container %v within %v. Container is in state %v", cstatus.Image, cstatus.Name, maxWaitForImageTime, waiting.Reason)
return true, errstr
}
}
Expand Down
10 changes: 6 additions & 4 deletions pkg/plugin/driver/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,13 @@ func TestPodFailing(t *testing.T) {
}, {
desc: "ImagePullBackOff is considered a failure if elapsed time greater than wait window",
expectFailing: true,
expectMsg: "Failed to pull image for container error-container within 5m0s. Container is in state ImagePullBackOff",
expectMsg: "Failed to pull image random-image for container error-container within 5m0s. Container is in state ImagePullBackOff",
pod: fromGoodPod(func(p *corev1.Pod) *corev1.Pod {
p.Status.StartTime = &metav1.Time{Time: time.Now().Add(-maxWaitForImageTime)}
p.Status.ContainerStatuses = []corev1.ContainerStatus{
{
Name: "error-container",
Name: "error-container",
Image: "random-image",
State: corev1.ContainerState{
Waiting: &corev1.ContainerStateWaiting{
Reason: "ImagePullBackOff",
Expand All @@ -126,12 +127,13 @@ func TestPodFailing(t *testing.T) {
}, {
desc: "ErrImagePull is considered a failure if elapsed time greater than wait window",
expectFailing: true,
expectMsg: "Failed to pull image for container error-container within 5m0s. Container is in state ErrImagePull",
expectMsg: "Failed to pull image random-image for container error-container within 5m0s. Container is in state ErrImagePull",
pod: fromGoodPod(func(p *corev1.Pod) *corev1.Pod {
p.Status.StartTime = &metav1.Time{Time: time.Now().Add(-maxWaitForImageTime)}
p.Status.ContainerStatuses = []corev1.ContainerStatus{
{
Name: "error-container",
Name: "error-container",
Image: "random-image",
State: corev1.ContainerState{
Waiting: &corev1.ContainerStateWaiting{
Reason: "ErrImagePull",
Expand Down