runtime.go 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. /*
  2. Copyright 2016 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package common
  14. import (
  15. "fmt"
  16. "path"
  17. "time"
  18. v1 "k8s.io/api/core/v1"
  19. "k8s.io/apimachinery/pkg/util/uuid"
  20. "k8s.io/kubernetes/pkg/kubelet/images"
  21. "k8s.io/kubernetes/test/e2e/framework"
  22. e2elog "k8s.io/kubernetes/test/e2e/framework/log"
  23. "github.com/onsi/ginkgo"
  24. "github.com/onsi/gomega"
  25. gomegatypes "github.com/onsi/gomega/types"
  26. )
  27. var _ = framework.KubeDescribe("Container Runtime", func() {
  28. f := framework.NewDefaultFramework("container-runtime")
  29. ginkgo.Describe("blackbox test", func() {
  30. ginkgo.Context("when starting a container that exits", func() {
  31. /*
  32. Release : v1.13
  33. Testname: Container Runtime, Restart Policy, Pod Phases
  34. Description: If the restart policy is set to ‘Always’, Pod MUST be restarted when terminated, If restart policy is ‘OnFailure’, Pod MUST be started only if it is terminated with non-zero exit code. If the restart policy is ‘Never’, Pod MUST never be restarted. All these three test cases MUST verify the restart counts accordingly.
  35. */
  36. framework.ConformanceIt("should run with the expected status [NodeConformance]", func() {
  37. restartCountVolumeName := "restart-count"
  38. restartCountVolumePath := "/restart-count"
  39. testContainer := v1.Container{
  40. Image: framework.BusyBoxImage,
  41. VolumeMounts: []v1.VolumeMount{
  42. {
  43. MountPath: restartCountVolumePath,
  44. Name: restartCountVolumeName,
  45. },
  46. },
  47. }
  48. testVolumes := []v1.Volume{
  49. {
  50. Name: restartCountVolumeName,
  51. VolumeSource: v1.VolumeSource{
  52. EmptyDir: &v1.EmptyDirVolumeSource{Medium: v1.StorageMediumMemory},
  53. },
  54. },
  55. }
  56. testCases := []struct {
  57. Name string
  58. RestartPolicy v1.RestartPolicy
  59. Phase v1.PodPhase
  60. State ContainerState
  61. RestartCount int32
  62. Ready bool
  63. }{
  64. {"terminate-cmd-rpa", v1.RestartPolicyAlways, v1.PodRunning, ContainerStateRunning, 2, true},
  65. {"terminate-cmd-rpof", v1.RestartPolicyOnFailure, v1.PodSucceeded, ContainerStateTerminated, 1, false},
  66. {"terminate-cmd-rpn", v1.RestartPolicyNever, v1.PodFailed, ContainerStateTerminated, 0, false},
  67. }
  68. for _, testCase := range testCases {
  69. // It failed at the 1st run, then succeeded at 2nd run, then run forever
  70. cmdScripts := `
  71. f=%s
  72. count=$(echo 'hello' >> $f ; wc -l $f | awk {'print $1'})
  73. if [ $count -eq 1 ]; then
  74. exit 1
  75. fi
  76. if [ $count -eq 2 ]; then
  77. exit 0
  78. fi
  79. while true; do sleep 1; done
  80. `
  81. tmpCmd := fmt.Sprintf(cmdScripts, path.Join(restartCountVolumePath, "restartCount"))
  82. testContainer.Name = testCase.Name
  83. testContainer.Command = []string{"sh", "-c", tmpCmd}
  84. terminateContainer := ConformanceContainer{
  85. PodClient: f.PodClient(),
  86. Container: testContainer,
  87. RestartPolicy: testCase.RestartPolicy,
  88. Volumes: testVolumes,
  89. }
  90. terminateContainer.Create()
  91. defer terminateContainer.Delete()
  92. ginkgo.By(fmt.Sprintf("Container '%s': should get the expected 'RestartCount'", testContainer.Name))
  93. gomega.Eventually(func() (int32, error) {
  94. status, err := terminateContainer.GetStatus()
  95. return status.RestartCount, err
  96. }, ContainerStatusRetryTimeout, ContainerStatusPollInterval).Should(gomega.Equal(testCase.RestartCount))
  97. ginkgo.By(fmt.Sprintf("Container '%s': should get the expected 'Phase'", testContainer.Name))
  98. gomega.Eventually(terminateContainer.GetPhase, ContainerStatusRetryTimeout, ContainerStatusPollInterval).Should(gomega.Equal(testCase.Phase))
  99. ginkgo.By(fmt.Sprintf("Container '%s': should get the expected 'Ready' condition", testContainer.Name))
  100. gomega.Expect(terminateContainer.IsReady()).Should(gomega.Equal(testCase.Ready))
  101. status, err := terminateContainer.GetStatus()
  102. framework.ExpectNoError(err)
  103. ginkgo.By(fmt.Sprintf("Container '%s': should get the expected 'State'", testContainer.Name))
  104. gomega.Expect(GetContainerState(status.State)).To(gomega.Equal(testCase.State))
  105. ginkgo.By(fmt.Sprintf("Container '%s': should be possible to delete [NodeConformance]", testContainer.Name))
  106. gomega.Expect(terminateContainer.Delete()).To(gomega.Succeed())
  107. gomega.Eventually(terminateContainer.Present, ContainerStatusRetryTimeout, ContainerStatusPollInterval).Should(gomega.BeFalse())
  108. }
  109. })
  110. })
  111. ginkgo.Context("on terminated container", func() {
  112. rootUser := int64(0)
  113. nonRootUser := int64(10000)
  114. // Create and then terminate the container under defined PodPhase to verify if termination message matches the expected output. Lastly delete the created container.
  115. matchTerminationMessage := func(container v1.Container, expectedPhase v1.PodPhase, expectedMsg gomegatypes.GomegaMatcher) {
  116. container.Name = "termination-message-container"
  117. c := ConformanceContainer{
  118. PodClient: f.PodClient(),
  119. Container: container,
  120. RestartPolicy: v1.RestartPolicyNever,
  121. }
  122. ginkgo.By("create the container")
  123. c.Create()
  124. defer c.Delete()
  125. ginkgo.By(fmt.Sprintf("wait for the container to reach %s", expectedPhase))
  126. gomega.Eventually(c.GetPhase, ContainerStatusRetryTimeout, ContainerStatusPollInterval).Should(gomega.Equal(expectedPhase))
  127. ginkgo.By("get the container status")
  128. status, err := c.GetStatus()
  129. framework.ExpectNoError(err)
  130. ginkgo.By("the container should be terminated")
  131. gomega.Expect(GetContainerState(status.State)).To(gomega.Equal(ContainerStateTerminated))
  132. ginkgo.By("the termination message should be set")
  133. e2elog.Logf("Expected: %v to match Container's Termination Message: %v --", expectedMsg, status.State.Terminated.Message)
  134. gomega.Expect(status.State.Terminated.Message).Should(expectedMsg)
  135. ginkgo.By("delete the container")
  136. gomega.Expect(c.Delete()).To(gomega.Succeed())
  137. }
  138. ginkgo.It("should report termination message [LinuxOnly] if TerminationMessagePath is set [NodeConformance]", func() {
  139. // Cannot mount files in Windows Containers.
  140. container := v1.Container{
  141. Image: framework.BusyBoxImage,
  142. Command: []string{"/bin/sh", "-c"},
  143. Args: []string{"/bin/echo -n DONE > /dev/termination-log"},
  144. TerminationMessagePath: "/dev/termination-log",
  145. SecurityContext: &v1.SecurityContext{
  146. RunAsUser: &rootUser,
  147. },
  148. }
  149. matchTerminationMessage(container, v1.PodSucceeded, gomega.Equal("DONE"))
  150. })
  151. /*
  152. Release: v1.15
  153. Name: Container Runtime, TerminationMessagePath, non-root user and non-default path
  154. Description: Create a pod with a container to run it as a non-root user with a custom TerminationMessagePath set. Pod redirects the output to the provided path successfully. When the container is terminated, the termination message MUST match the expected output logged in the provided custom path.
  155. [LinuxOnly]: Tagged LinuxOnly due to use of 'uid' and unable to mount files in Windows Containers.
  156. */
  157. framework.ConformanceIt("should report termination message [LinuxOnly] if TerminationMessagePath is set as non-root user and at a non-default path [NodeConformance]", func() {
  158. container := v1.Container{
  159. Image: framework.BusyBoxImage,
  160. Command: []string{"/bin/sh", "-c"},
  161. Args: []string{"/bin/echo -n DONE > /dev/termination-custom-log"},
  162. TerminationMessagePath: "/dev/termination-custom-log",
  163. SecurityContext: &v1.SecurityContext{
  164. RunAsUser: &nonRootUser,
  165. },
  166. }
  167. matchTerminationMessage(container, v1.PodSucceeded, gomega.Equal("DONE"))
  168. })
  169. /*
  170. Release: v1.15
  171. Name: Container Runtime, TerminationMessage, from container's log output of failing container
  172. Description: Create a pod with an container. Container's output is recorded in log and container exits with an error. When container is terminated, termination message MUST match the expected output recorded from container's log.
  173. [LinuxOnly]: Cannot mount files in Windows Containers.
  174. */
  175. framework.ConformanceIt("should report termination message [LinuxOnly] from log output if TerminationMessagePolicy FallbackToLogsOnError is set [NodeConformance]", func() {
  176. container := v1.Container{
  177. Image: framework.BusyBoxImage,
  178. Command: []string{"/bin/sh", "-c"},
  179. Args: []string{"/bin/echo -n DONE; /bin/false"},
  180. TerminationMessagePath: "/dev/termination-log",
  181. TerminationMessagePolicy: v1.TerminationMessageFallbackToLogsOnError,
  182. }
  183. matchTerminationMessage(container, v1.PodFailed, gomega.Equal("DONE"))
  184. })
  185. /*
  186. Release: v1.15
  187. Name: Container Runtime, TerminationMessage, from log output of succeeding container
  188. Description: Create a pod with an container. Container's output is recorded in log and container exits successfully without an error. When container is terminated, terminationMessage MUST have no content as container succeed.
  189. [LinuxOnly]: Cannot mount files in Windows Containers.
  190. */
  191. framework.ConformanceIt("should report termination message [LinuxOnly] as empty when pod succeeds and TerminationMessagePolicy FallbackToLogsOnError is set [NodeConformance]", func() {
  192. container := v1.Container{
  193. Image: framework.BusyBoxImage,
  194. Command: []string{"/bin/sh", "-c"},
  195. Args: []string{"/bin/echo -n DONE; /bin/true"},
  196. TerminationMessagePath: "/dev/termination-log",
  197. TerminationMessagePolicy: v1.TerminationMessageFallbackToLogsOnError,
  198. }
  199. matchTerminationMessage(container, v1.PodSucceeded, gomega.Equal(""))
  200. })
  201. /*
  202. Release: v1.15
  203. Name: Container Runtime, TerminationMessage, from file of succeeding container
  204. Description: Create a pod with an container. Container's output is recorded in a file and the container exits successfully without an error. When container is terminated, terminationMessage MUST match with the content from file.
  205. [LinuxOnly]: Cannot mount files in Windows Containers.
  206. */
  207. framework.ConformanceIt("should report termination message [LinuxOnly] from file when pod succeeds and TerminationMessagePolicy FallbackToLogsOnError is set [NodeConformance]", func() {
  208. container := v1.Container{
  209. Image: framework.BusyBoxImage,
  210. Command: []string{"/bin/sh", "-c"},
  211. Args: []string{"/bin/echo -n OK > /dev/termination-log; /bin/echo DONE; /bin/true"},
  212. TerminationMessagePath: "/dev/termination-log",
  213. TerminationMessagePolicy: v1.TerminationMessageFallbackToLogsOnError,
  214. }
  215. matchTerminationMessage(container, v1.PodSucceeded, gomega.Equal("OK"))
  216. })
  217. })
  218. ginkgo.Context("when running a container with a new image", func() {
  219. // Images used for ConformanceContainer are not added into NodeImageWhiteList, because this test is
  220. // testing image pulling, these images don't need to be prepulled. The ImagePullPolicy
  221. // is v1.PullAlways, so it won't be blocked by framework image white list check.
  222. imagePullTest := func(image string, hasSecret bool, expectedPhase v1.PodPhase, expectedPullStatus bool, windowsImage bool) {
  223. command := []string{"/bin/sh", "-c", "while true; do sleep 1; done"}
  224. if windowsImage {
  225. // -t: Ping the specified host until stopped.
  226. command = []string{"ping", "-t", "localhost"}
  227. }
  228. container := ConformanceContainer{
  229. PodClient: f.PodClient(),
  230. Container: v1.Container{
  231. Name: "image-pull-test",
  232. Image: image,
  233. Command: command,
  234. ImagePullPolicy: v1.PullAlways,
  235. },
  236. RestartPolicy: v1.RestartPolicyNever,
  237. }
  238. if hasSecret {
  239. // The service account only has pull permission
  240. auth := `
  241. {
  242. "auths": {
  243. "https://gcr.io": {
  244. "auth": "X2pzb25fa2V5OnsKICAidHlwZSI6ICJzZXJ2aWNlX2FjY291bnQiLAogICJwcm9qZWN0X2lkIjogImF1dGhlbnRpY2F0ZWQtaW1hZ2UtcHVsbGluZyIsCiAgInByaXZhdGVfa2V5X2lkIjogImI5ZjJhNjY0YWE5YjIwNDg0Y2MxNTg2MDYzZmVmZGExOTIyNGFjM2IiLAogICJwcml2YXRlX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Zk1Rbk5oNFNZR0VlQlQzMlpxQ1RcbkpSZ2YwWGpveXZ2dXA5eFhqTWtYcnBZL3ljMXpmcVRaQzBNTzkvMVVjMWJSR2RaMmR5M2xSNU5XYXA3T1h5Zk9cblBQcE5Gb1BUWGd2M3FDcW5sTEhyR3pNPVxuLS0tLS1FTkQgUFJJVkFURSBLRVktLS0tLVxuIiwKICAiY2xpZW50X2VtYWlsIjogImltYWdlLXB1bGxpbmdAYXV0aGVudGljYXRlZC1pbWFnZS1wdWxsaW5nLmlhbS5nc2VydmljZWFjY291bnQuY29tIiwKICAiY2xpZW50X2lkIjogIjExMzc5NzkxNDUzMDA3MzI3ODcxMiIsCiAgImF1dGhfdXJpIjogImh0dHBzOi8vYWNjb3VudHMuZ29vZ2xlLmNvbS9vL29hdXRoMi9hdXRoIiwKICAidG9rZW5fdXJpIjogImh0dHBzOi8vYWNjb3VudHMuZ29vZ2xlLmNvbS9vL29hdXRoMi90b2tlbiIsCiAgImF1dGhfcHJvdmlkZXJfeDUwOV9jZXJ0X3VybCI6ICJodHRwczovL3d3dy5nb29nbGVhcGlzLmNvbS9vYXV0aDIvdjEvY2VydHMiLAogICJjbGllbnRfeDUwOV9jZXJ0X3VybCI6ICJodHRwczovL3d3dy5nb29nbGVhcGlzLmNvbS9yb2JvdC92MS9tZXRhZGF0YS94NTA5L2ltYWdlLXB1bGxpbmclNDBhdXRoZW50aWNhdGVkLWltYWdlLXB1bGxpbmcuaWFtLmdzZXJ2aWNlYWNjb3VudC5jb20iCn0=",
  245. "email": "image-pulling@authenticated-image-pulling.iam.gserviceaccount.com"
  246. }
  247. }
  248. }`
  249. secret := &v1.Secret{
  250. Data: map[string][]byte{v1.DockerConfigJsonKey: []byte(auth)},
  251. Type: v1.SecretTypeDockerConfigJson,
  252. }
  253. secret.Name = "image-pull-secret-" + string(uuid.NewUUID())
  254. ginkgo.By("create image pull secret")
  255. _, err := f.ClientSet.CoreV1().Secrets(f.Namespace.Name).Create(secret)
  256. framework.ExpectNoError(err)
  257. defer f.ClientSet.CoreV1().Secrets(f.Namespace.Name).Delete(secret.Name, nil)
  258. container.ImagePullSecrets = []string{secret.Name}
  259. }
  260. // checkContainerStatus checks whether the container status matches expectation.
  261. checkContainerStatus := func() error {
  262. status, err := container.GetStatus()
  263. if err != nil {
  264. return fmt.Errorf("failed to get container status: %v", err)
  265. }
  266. // We need to check container state first. The default pod status is pending, If we check pod phase first,
  267. // and the expected pod phase is Pending, the container status may not even show up when we check it.
  268. // Check container state
  269. if !expectedPullStatus {
  270. if status.State.Running == nil {
  271. return fmt.Errorf("expected container state: Running, got: %q",
  272. GetContainerState(status.State))
  273. }
  274. }
  275. if expectedPullStatus {
  276. if status.State.Waiting == nil {
  277. return fmt.Errorf("expected container state: Waiting, got: %q",
  278. GetContainerState(status.State))
  279. }
  280. reason := status.State.Waiting.Reason
  281. if reason != images.ErrImagePull.Error() &&
  282. reason != images.ErrImagePullBackOff.Error() {
  283. return fmt.Errorf("unexpected waiting reason: %q", reason)
  284. }
  285. }
  286. // Check pod phase
  287. phase, err := container.GetPhase()
  288. if err != nil {
  289. return fmt.Errorf("failed to get pod phase: %v", err)
  290. }
  291. if phase != expectedPhase {
  292. return fmt.Errorf("expected pod phase: %q, got: %q", expectedPhase, phase)
  293. }
  294. return nil
  295. }
  296. // The image registry is not stable, which sometimes causes the test to fail. Add retry mechanism to make this less flaky.
  297. const flakeRetry = 3
  298. for i := 1; i <= flakeRetry; i++ {
  299. var err error
  300. ginkgo.By("create the container")
  301. container.Create()
  302. ginkgo.By("check the container status")
  303. for start := time.Now(); time.Since(start) < ContainerStatusRetryTimeout; time.Sleep(ContainerStatusPollInterval) {
  304. if err = checkContainerStatus(); err == nil {
  305. break
  306. }
  307. }
  308. ginkgo.By("delete the container")
  309. container.Delete()
  310. if err == nil {
  311. break
  312. }
  313. if i < flakeRetry {
  314. e2elog.Logf("No.%d attempt failed: %v, retrying...", i, err)
  315. } else {
  316. framework.Failf("All %d attempts failed: %v", flakeRetry, err)
  317. }
  318. }
  319. }
  320. ginkgo.It("should not be able to pull image from invalid registry [NodeConformance]", func() {
  321. image := "invalid.com/invalid/alpine:3.1"
  322. imagePullTest(image, false, v1.PodPending, true, false)
  323. })
  324. ginkgo.It("should not be able to pull non-existing image from gcr.io [NodeConformance]", func() {
  325. image := "k8s.gcr.io/invalid-image:invalid-tag"
  326. imagePullTest(image, false, v1.PodPending, true, false)
  327. })
  328. ginkgo.It("should be able to pull image from gcr.io [LinuxOnly] [NodeConformance]", func() {
  329. image := "gcr.io/google-containers/debian-base:0.4.1"
  330. imagePullTest(image, false, v1.PodRunning, false, false)
  331. })
  332. ginkgo.It("should be able to pull image from gcr.io [NodeConformance]", func() {
  333. framework.SkipUnlessNodeOSDistroIs("windows")
  334. image := "gcr.io/kubernetes-e2e-test-images/windows-nanoserver:v1"
  335. imagePullTest(image, false, v1.PodRunning, false, true)
  336. })
  337. ginkgo.It("should be able to pull image from docker hub [LinuxOnly] [NodeConformance]", func() {
  338. image := "alpine:3.7"
  339. imagePullTest(image, false, v1.PodRunning, false, false)
  340. })
  341. ginkgo.It("should be able to pull image from docker hub [NodeConformance]", func() {
  342. framework.SkipUnlessNodeOSDistroIs("windows")
  343. // TODO(claudiub): Switch to nanoserver image manifest list.
  344. image := "e2eteam/busybox:1.29"
  345. imagePullTest(image, false, v1.PodRunning, false, true)
  346. })
  347. ginkgo.It("should not be able to pull from private registry without secret [NodeConformance]", func() {
  348. image := "gcr.io/authenticated-image-pulling/alpine:3.7"
  349. imagePullTest(image, false, v1.PodPending, true, false)
  350. })
  351. ginkgo.It("should be able to pull from private registry with secret [LinuxOnly] [NodeConformance]", func() {
  352. image := "gcr.io/authenticated-image-pulling/alpine:3.7"
  353. imagePullTest(image, true, v1.PodRunning, false, false)
  354. })
  355. ginkgo.It("should be able to pull from private registry with secret [NodeConformance]", func() {
  356. framework.SkipUnlessNodeOSDistroIs("windows")
  357. image := "gcr.io/authenticated-image-pulling/windows-nanoserver:v1"
  358. imagePullTest(image, true, v1.PodRunning, false, true)
  359. })
  360. })
  361. })
  362. })