2016-04-23 02:50:02 +00:00
|
|
|
/*
|
2016-06-03 00:25:58 +00:00
|
|
|
Copyright 2016 The Kubernetes Authors.
|
2016-04-23 02:50:02 +00:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package e2e_node
|
|
|
|
|
|
|
|
import (
|
2016-05-06 07:30:16 +00:00
|
|
|
"fmt"
|
|
|
|
"path"
|
2016-04-23 02:50:02 +00:00
|
|
|
"time"
|
|
|
|
|
|
|
|
"k8s.io/kubernetes/pkg/api"
|
2016-07-19 22:42:21 +00:00
|
|
|
"k8s.io/kubernetes/pkg/kubelet/images"
|
2016-07-26 15:13:18 +00:00
|
|
|
"k8s.io/kubernetes/pkg/util/uuid"
|
2016-06-14 08:16:13 +00:00
|
|
|
"k8s.io/kubernetes/test/e2e/framework"
|
2016-04-23 02:50:02 +00:00
|
|
|
|
|
|
|
. "github.com/onsi/ginkgo"
|
|
|
|
. "github.com/onsi/gomega"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2016-06-14 08:16:13 +00:00
|
|
|
consistentCheckTimeout = time.Second * 5
|
2016-05-16 22:58:42 +00:00
|
|
|
retryTimeout = time.Minute * 5
|
2016-06-14 08:16:13 +00:00
|
|
|
pollInterval = time.Second * 1
|
2016-04-23 02:50:02 +00:00
|
|
|
)
|
|
|
|
|
2016-06-14 08:16:13 +00:00
|
|
|
var _ = framework.KubeDescribe("Container Runtime Conformance Test", func() {
|
2016-07-08 05:56:46 +00:00
|
|
|
f := framework.NewDefaultFramework("runtime-conformance")
|
2016-04-23 02:50:02 +00:00
|
|
|
|
2016-05-06 07:30:16 +00:00
|
|
|
Describe("container runtime conformance blackbox test", func() {
|
2016-06-05 07:38:13 +00:00
|
|
|
Context("when starting a container that exits", func() {
|
2016-05-06 07:30:16 +00:00
|
|
|
It("it should run with the expected status [Conformance]", func() {
|
2016-06-05 07:38:13 +00:00
|
|
|
restartCountVolumeName := "restart-count"
|
|
|
|
restartCountVolumePath := "/restart-count"
|
2016-05-06 07:30:16 +00:00
|
|
|
testContainer := api.Container{
|
2016-05-20 03:04:58 +00:00
|
|
|
Image: ImageRegistry[busyBoxImage],
|
2016-05-06 07:30:16 +00:00
|
|
|
VolumeMounts: []api.VolumeMount{
|
|
|
|
{
|
2016-06-05 07:38:13 +00:00
|
|
|
MountPath: restartCountVolumePath,
|
|
|
|
Name: restartCountVolumeName,
|
2016-05-06 07:30:16 +00:00
|
|
|
},
|
2016-04-23 02:50:02 +00:00
|
|
|
},
|
2016-05-06 07:30:16 +00:00
|
|
|
}
|
|
|
|
testVolumes := []api.Volume{
|
|
|
|
{
|
2016-06-05 07:38:13 +00:00
|
|
|
Name: restartCountVolumeName,
|
2016-05-06 07:30:16 +00:00
|
|
|
VolumeSource: api.VolumeSource{
|
2016-06-23 19:31:28 +00:00
|
|
|
EmptyDir: &api.EmptyDirVolumeSource{Medium: api.StorageMediumMemory},
|
2016-05-06 07:30:16 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2016-06-14 08:16:13 +00:00
|
|
|
testCases := []struct {
|
|
|
|
Name string
|
|
|
|
RestartPolicy api.RestartPolicy
|
|
|
|
Phase api.PodPhase
|
|
|
|
State ContainerState
|
|
|
|
RestartCount int32
|
|
|
|
Ready bool
|
|
|
|
}{
|
|
|
|
{"terminate-cmd-rpa", api.RestartPolicyAlways, api.PodRunning, ContainerStateRunning, 2, true},
|
|
|
|
{"terminate-cmd-rpof", api.RestartPolicyOnFailure, api.PodSucceeded, ContainerStateTerminated, 1, false},
|
|
|
|
{"terminate-cmd-rpn", api.RestartPolicyNever, api.PodFailed, ContainerStateTerminated, 0, false},
|
2016-04-23 02:50:02 +00:00
|
|
|
}
|
2016-06-05 07:38:13 +00:00
|
|
|
for _, testCase := range testCases {
|
2016-04-23 02:50:02 +00:00
|
|
|
|
2016-06-05 07:38:13 +00:00
|
|
|
// It failed at the 1st run, then succeeded at 2nd run, then run forever
|
|
|
|
cmdScripts := `
|
|
|
|
f=%s
|
|
|
|
count=$(echo 'hello' >> $f ; wc -l $f | awk {'print $1'})
|
|
|
|
if [ $count -eq 1 ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ $count -eq 2 ]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
while true; do sleep 1; done
|
|
|
|
`
|
2016-06-23 19:31:28 +00:00
|
|
|
tmpCmd := fmt.Sprintf(cmdScripts, path.Join(restartCountVolumePath, "restartCount"))
|
2016-06-05 07:38:13 +00:00
|
|
|
testContainer.Name = testCase.Name
|
2016-05-06 07:30:16 +00:00
|
|
|
testContainer.Command = []string{"sh", "-c", tmpCmd}
|
|
|
|
terminateContainer := ConformanceContainer{
|
2016-07-08 05:56:46 +00:00
|
|
|
PodClient: f.PodClient(),
|
2016-05-06 07:30:16 +00:00
|
|
|
Container: testContainer,
|
2016-06-05 07:38:13 +00:00
|
|
|
RestartPolicy: testCase.RestartPolicy,
|
2016-05-06 07:30:16 +00:00
|
|
|
Volumes: testVolumes,
|
2016-06-23 19:31:28 +00:00
|
|
|
PodSecurityContext: &api.PodSecurityContext{
|
|
|
|
SELinuxOptions: &api.SELinuxOptions{
|
|
|
|
Level: "s0",
|
|
|
|
},
|
|
|
|
},
|
2016-05-06 07:30:16 +00:00
|
|
|
}
|
2016-06-29 00:20:08 +00:00
|
|
|
terminateContainer.Create()
|
2016-06-05 07:38:13 +00:00
|
|
|
defer terminateContainer.Delete()
|
2016-05-06 07:30:16 +00:00
|
|
|
|
|
|
|
By("it should get the expected 'RestartCount'")
|
2016-06-05 07:38:13 +00:00
|
|
|
Eventually(func() (int32, error) {
|
|
|
|
status, err := terminateContainer.GetStatus()
|
|
|
|
return status.RestartCount, err
|
2016-06-14 08:16:13 +00:00
|
|
|
}, retryTimeout, pollInterval).Should(Equal(testCase.RestartCount))
|
2016-05-06 07:30:16 +00:00
|
|
|
|
2016-06-05 07:38:13 +00:00
|
|
|
By("it should get the expected 'Phase'")
|
|
|
|
Eventually(terminateContainer.GetPhase, retryTimeout, pollInterval).Should(Equal(testCase.Phase))
|
2016-05-06 07:30:16 +00:00
|
|
|
|
2016-06-05 07:38:13 +00:00
|
|
|
By("it should get the expected 'Ready' condition")
|
|
|
|
Expect(terminateContainer.IsReady()).Should(Equal(testCase.Ready))
|
2016-05-06 07:30:16 +00:00
|
|
|
|
2016-06-05 07:38:13 +00:00
|
|
|
status, err := terminateContainer.GetStatus()
|
|
|
|
Expect(err).ShouldNot(HaveOccurred())
|
2016-05-06 07:30:16 +00:00
|
|
|
|
|
|
|
By("it should get the expected 'State'")
|
2016-06-05 07:38:13 +00:00
|
|
|
Expect(GetContainerState(status.State)).To(Equal(testCase.State))
|
2016-05-06 07:30:16 +00:00
|
|
|
|
|
|
|
By("it should be possible to delete [Conformance]")
|
2016-06-05 07:38:13 +00:00
|
|
|
Expect(terminateContainer.Delete()).To(Succeed())
|
|
|
|
Eventually(terminateContainer.Present, retryTimeout, pollInterval).Should(BeFalse())
|
2016-05-06 07:30:16 +00:00
|
|
|
}
|
|
|
|
})
|
2016-06-13 21:38:24 +00:00
|
|
|
|
|
|
|
It("should report termination message if TerminationMessagePath is set [Conformance]", func() {
|
|
|
|
name := "termination-message-container"
|
|
|
|
terminationMessage := "DONE"
|
|
|
|
terminationMessagePath := "/dev/termination-log"
|
2016-06-24 23:34:13 +00:00
|
|
|
priv := true
|
2016-06-13 21:38:24 +00:00
|
|
|
c := ConformanceContainer{
|
2016-07-08 05:56:46 +00:00
|
|
|
PodClient: f.PodClient(),
|
2016-06-13 21:38:24 +00:00
|
|
|
Container: api.Container{
|
|
|
|
Image: ImageRegistry[busyBoxImage],
|
|
|
|
Name: name,
|
|
|
|
Command: []string{"/bin/sh", "-c"},
|
|
|
|
Args: []string{fmt.Sprintf("/bin/echo -n %s > %s", terminationMessage, terminationMessagePath)},
|
|
|
|
TerminationMessagePath: terminationMessagePath,
|
2016-06-24 23:34:13 +00:00
|
|
|
SecurityContext: &api.SecurityContext{
|
|
|
|
Privileged: &priv,
|
|
|
|
},
|
2016-06-13 21:38:24 +00:00
|
|
|
},
|
|
|
|
RestartPolicy: api.RestartPolicyNever,
|
|
|
|
}
|
|
|
|
|
|
|
|
By("create the container")
|
2016-06-29 00:20:08 +00:00
|
|
|
c.Create()
|
2016-06-13 21:38:24 +00:00
|
|
|
defer c.Delete()
|
|
|
|
|
|
|
|
By("wait for the container to succeed")
|
|
|
|
Eventually(c.GetPhase, retryTimeout, pollInterval).Should(Equal(api.PodSucceeded))
|
|
|
|
|
|
|
|
By("get the container status")
|
|
|
|
status, err := c.GetStatus()
|
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
|
|
|
|
By("the container should be terminated")
|
|
|
|
Expect(GetContainerState(status.State)).To(Equal(ContainerStateTerminated))
|
|
|
|
|
|
|
|
By("the termination message should be set")
|
|
|
|
Expect(status.State.Terminated.Message).Should(Equal(terminationMessage))
|
|
|
|
|
|
|
|
By("delete the container")
|
|
|
|
Expect(c.Delete()).To(Succeed())
|
|
|
|
})
|
2016-04-23 02:50:02 +00:00
|
|
|
})
|
2016-05-06 07:30:16 +00:00
|
|
|
|
2016-06-14 08:16:13 +00:00
|
|
|
Context("when running a container with a new image", func() {
|
|
|
|
// The service account only has pull permission
|
|
|
|
auth := `
|
|
|
|
{
|
|
|
|
"auths": {
|
|
|
|
"https://gcr.io": {
|
|
|
|
"auth": "X2pzb25fa2V5OnsKICAidHlwZSI6ICJzZXJ2aWNlX2FjY291bnQiLAogICJwcm9qZWN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cbmpQUnArdjhjY21MK3dTZzhQTGprM3ZsN2VlNXJsWWxNQndNdUdjUHhBb0dBZWRueGJXMVJMbVZubEFpSEx1L0xcbmxtZkF3RFdtRWlJMFVnK1BMbm9Pdk81dFE1ZDRXMS94RU44bFA0cWtzcGtmZk1Rbk5oNFNZR0VlQlQzMlpxQ1RcbkpSZ2YwWGpveXZ2dXA5eFhqTWtYcnBZL3ljMXpmcVRaQzBNTzkvMVVjMWJSR2RaMmR5M2xSNU5XYXA3T1h5Zk9cblBQcE5Gb1BUWGd2M3FDcW5sTEhyR3pNPVxuLS0tLS1FTkQgUFJJVkFURSBLRVktLS0tLVxuIiwKICAiY2xpZW50X2VtYWlsIjogImltYWdlLXB1bGxpbmdAYXV0aGVudGljYXRlZC1pbWFnZS1wdWxsaW5nLmlhbS5nc2VydmljZWFjY291bnQuY29tIiwKICAiY2xpZW50X2lkIjogIjExMzc5NzkxNDUzMDA3MzI3ODcxMiIsCiAgImF1dGhfdXJpIjogImh0dHBzOi8vYWNjb3VudHMuZ29vZ2xlLmNvbS9vL29hdXRoMi9hdXRoIiwKICAidG9rZW5fdXJpIjogImh0dHBzOi8vYWNjb3VudHMuZ29vZ2xlLmNvbS9vL29hdXRoMi90b2tlbiIsCiAgImF1dGhfcHJvdmlkZXJfeDUwOV9jZXJ0X3VybCI6ICJodHRwczovL3d3dy5nb29nbGVhcGlzLmNvbS9vYXV0aDIvdjEvY2VydHMiLAogICJjbGllbnRfeDUwOV9jZXJ0X3VybCI6ICJodHRwczovL3d3dy5nb29nbGVhcGlzLmNvbS9yb2JvdC92MS9tZXRhZGF0YS94NTA5L2ltYWdlLXB1bGxpbmclNDBhdXRoZW50aWNhdGVkLWltYWdlLXB1bGxpbmcuaWFtLmdzZXJ2aWNlYWNjb3VudC5jb20iCn0=",
|
|
|
|
"email": "image-pulling@authenticated-image-pulling.iam.gserviceaccount.com"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}`
|
|
|
|
secret := &api.Secret{
|
|
|
|
Data: map[string][]byte{api.DockerConfigJsonKey: []byte(auth)},
|
|
|
|
Type: api.SecretTypeDockerConfigJson,
|
|
|
|
}
|
|
|
|
for _, testCase := range []struct {
|
|
|
|
description string
|
|
|
|
image string
|
|
|
|
secret bool
|
|
|
|
phase api.PodPhase
|
2016-07-06 00:08:37 +00:00
|
|
|
waiting bool
|
2016-06-14 08:16:13 +00:00
|
|
|
}{
|
|
|
|
{
|
|
|
|
description: "should not be able to pull image from invalid registry",
|
|
|
|
image: "invalid.com/invalid/alpine:3.1",
|
|
|
|
phase: api.PodPending,
|
2016-07-06 00:08:37 +00:00
|
|
|
waiting: true,
|
2016-06-14 08:16:13 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
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,
|
2016-07-06 00:08:37 +00:00
|
|
|
waiting: true,
|
2016-06-14 08:16:13 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
description: "should be able to pull image from gcr.io",
|
|
|
|
image: NoPullImageRegistry[pullTestAlpineWithBash],
|
|
|
|
phase: api.PodRunning,
|
2016-07-06 00:08:37 +00:00
|
|
|
waiting: false,
|
2016-06-14 08:16:13 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
description: "should be able to pull image from docker hub",
|
|
|
|
image: NoPullImageRegistry[pullTestAlpine],
|
|
|
|
phase: api.PodRunning,
|
2016-07-06 00:08:37 +00:00
|
|
|
waiting: false,
|
2016-06-14 08:16:13 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
description: "should not be able to pull from private registry without secret",
|
|
|
|
image: NoPullImageRegistry[pullTestAuthenticatedAlpine],
|
|
|
|
phase: api.PodPending,
|
2016-07-06 00:08:37 +00:00
|
|
|
waiting: true,
|
2016-06-14 08:16:13 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
description: "should be able to pull from private registry with secret",
|
|
|
|
image: NoPullImageRegistry[pullTestAuthenticatedAlpine],
|
|
|
|
secret: true,
|
|
|
|
phase: api.PodRunning,
|
2016-07-06 00:08:37 +00:00
|
|
|
waiting: false,
|
2016-06-14 08:16:13 +00:00
|
|
|
},
|
|
|
|
} {
|
|
|
|
testCase := testCase
|
|
|
|
It(testCase.description, func() {
|
|
|
|
name := "image-pull-test"
|
|
|
|
command := []string{"/bin/sh", "-c", "while true; do sleep 1; done"}
|
|
|
|
container := ConformanceContainer{
|
2016-07-08 05:56:46 +00:00
|
|
|
PodClient: f.PodClient(),
|
2016-06-14 08:16:13 +00:00
|
|
|
Container: api.Container{
|
|
|
|
Name: name,
|
|
|
|
Image: testCase.image,
|
|
|
|
Command: command,
|
|
|
|
// PullAlways makes sure that the image will always be pulled even if it is present before the test.
|
|
|
|
ImagePullPolicy: api.PullAlways,
|
|
|
|
},
|
|
|
|
RestartPolicy: api.RestartPolicyNever,
|
|
|
|
}
|
|
|
|
if testCase.secret {
|
2016-07-26 15:13:18 +00:00
|
|
|
secret.Name = "image-pull-secret-" + string(uuid.NewUUID())
|
2016-06-14 08:16:13 +00:00
|
|
|
By("create image pull secret")
|
|
|
|
_, err := f.Client.Secrets(f.Namespace.Name).Create(secret)
|
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
defer f.Client.Secrets(f.Namespace.Name).Delete(secret.Name)
|
|
|
|
container.ImagePullSecrets = []string{secret.Name}
|
|
|
|
}
|
2016-04-23 02:50:02 +00:00
|
|
|
|
2016-06-14 08:16:13 +00:00
|
|
|
By("create the container")
|
2016-06-29 00:20:08 +00:00
|
|
|
container.Create()
|
2016-06-14 08:16:13 +00:00
|
|
|
defer container.Delete()
|
2016-05-06 07:30:16 +00:00
|
|
|
|
2016-07-01 00:00:22 +00:00
|
|
|
// We need to check container state first. The default pod status is pending, If we check
|
|
|
|
// pod phase first, and the expected pod phase is Pending, the container status may not
|
|
|
|
// even show up when we check it.
|
2016-06-14 08:16:13 +00:00
|
|
|
By("check the container state")
|
2016-07-06 00:08:37 +00:00
|
|
|
checkContainerState := func() (bool, error) {
|
2016-07-01 00:00:22 +00:00
|
|
|
status, err := container.GetStatus()
|
|
|
|
if err != nil {
|
2016-07-06 00:08:37 +00:00
|
|
|
return false, err
|
2016-07-01 00:00:22 +00:00
|
|
|
}
|
2016-07-06 00:08:37 +00:00
|
|
|
if !testCase.waiting && status.State.Running != nil {
|
|
|
|
return true, nil
|
|
|
|
}
|
|
|
|
if testCase.waiting && status.State.Waiting != nil {
|
|
|
|
reason := status.State.Waiting.Reason
|
2016-07-19 22:42:21 +00:00
|
|
|
return reason == images.ErrImagePull.Error() ||
|
|
|
|
reason == images.ErrImagePullBackOff.Error(), nil
|
2016-07-06 00:08:37 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
return false, nil
|
2016-07-01 00:00:22 +00:00
|
|
|
}
|
2016-07-06 00:08:37 +00:00
|
|
|
Eventually(checkContainerState, retryTimeout, pollInterval).Should(BeTrue())
|
|
|
|
Consistently(checkContainerState, consistentCheckTimeout, pollInterval).Should(BeTrue())
|
2016-07-01 00:00:22 +00:00
|
|
|
|
|
|
|
By("check the pod phase")
|
|
|
|
Expect(container.GetPhase()).To(Equal(testCase.phase))
|
2016-05-06 07:30:16 +00:00
|
|
|
|
2016-06-14 08:16:13 +00:00
|
|
|
By("it should be possible to delete")
|
|
|
|
Expect(container.Delete()).To(Succeed())
|
|
|
|
Eventually(container.Present, retryTimeout, pollInterval).Should(BeFalse())
|
|
|
|
})
|
|
|
|
}
|
2016-05-06 07:30:16 +00:00
|
|
|
})
|
2016-04-23 02:50:02 +00:00
|
|
|
})
|
|
|
|
})
|