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

Node E2E: Use waiting reason to figure out image pulling error. #28517

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 22 additions & 12 deletions test/e2e_node/runtime_conformance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"time"

"k8s.io/kubernetes/pkg/api"
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/test/e2e/framework"

Expand Down Expand Up @@ -187,44 +188,44 @@ while true; do sleep 1; done
image string
secret bool
phase api.PodPhase
state ContainerState
waiting bool
}{
{
description: "should not be able to pull image from invalid registry",
image: "invalid.com/invalid/alpine:3.1",
phase: api.PodPending,
state: ContainerStateWaiting,
waiting: true,
},
{
description: "should not be able to pull non-existing image from gcr.io",
image: "gcr.io/google_containers/invalid-image:invalid-tag",
phase: api.PodPending,
state: ContainerStateWaiting,
waiting: true,
},
{
description: "should be able to pull image from gcr.io",
image: NoPullImageRegistry[pullTestAlpineWithBash],
phase: api.PodRunning,
state: ContainerStateRunning,
waiting: false,
},
{
description: "should be able to pull image from docker hub",
image: NoPullImageRegistry[pullTestAlpine],
phase: api.PodRunning,
state: ContainerStateRunning,
waiting: false,
},
{
description: "should not be able to pull from private registry without secret",
image: NoPullImageRegistry[pullTestAuthenticatedAlpine],
phase: api.PodPending,
state: ContainerStateWaiting,
waiting: true,
},
{
description: "should be able to pull from private registry with secret",
image: NoPullImageRegistry[pullTestAuthenticatedAlpine],
secret: true,
phase: api.PodRunning,
state: ContainerStateRunning,
waiting: false,
},
} {
testCase := testCase
Expand Down Expand Up @@ -259,15 +260,24 @@ while true; do sleep 1; done
// pod phase first, and the expected pod phase is Pending, the container status may not
// even show up when we check it.
By("check the container state")
getState := func() (ContainerState, error) {
checkContainerState := func() (bool, error) {
status, err := container.GetStatus()
if err != nil {
return ContainerStateUnknown, err
return false, err
}
return GetContainerState(status.State), nil
if !testCase.waiting && status.State.Running != nil {
return true, nil
}
if testCase.waiting && status.State.Waiting != nil {
reason := status.State.Waiting.Reason
return reason == kubecontainer.ErrImagePull.Error() ||
reason == kubecontainer.ErrImagePullBackOff.Error(), nil

}
return false, nil
}
Eventually(getState, retryTimeout, pollInterval).Should(Equal(testCase.state))
Consistently(getState, consistentCheckTimeout, pollInterval).Should(Equal(testCase.state))
Eventually(checkContainerState, retryTimeout, pollInterval).Should(BeTrue())
Consistently(checkContainerState, consistentCheckTimeout, pollInterval).Should(BeTrue())

By("check the pod phase")
Expect(container.GetPhase()).To(Equal(testCase.phase))
Expand Down