diff --git a/test/e2e_node/oomkiller_linux_test.go b/test/e2e_node/oomkiller_linux_test.go index 43ccabc8033..f044f24f8a2 100644 --- a/test/e2e_node/oomkiller_linux_test.go +++ b/test/e2e_node/oomkiller_linux_test.go @@ -41,12 +41,20 @@ var _ = SIGDescribe("OOMKiller [LinuxOnly] [NodeConformance]", func() { f := framework.NewDefaultFramework("oomkiller-test") f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged - testCases := []testCase{{ - name: "single process container", - oomTargetContainerName: "oomkill-single-target-container", - podSpec: getOOMTargetPod("oomkill-target-pod", "oomkill-single-target-container", - getOOMTargetContainer), - }} + testCases := []testCase{ + { + name: "single process container", + oomTargetContainerName: "oomkill-single-target-container", + podSpec: getOOMTargetPod("oomkill-target-pod", "oomkill-single-target-container", + getOOMTargetContainer), + }, + { + name: "init container", + oomTargetContainerName: "oomkill-target-init-container", + podSpec: getInitContainerOOMTargetPod("initcontinar-oomkill-target-pod", "oomkill-target-init-container", + getOOMTargetContainer), + }, + } // If using cgroup v2, we set memory.oom.group=1 for the container cgroup so that any process which gets OOM killed // in the process, causes all processes in the container to get OOM killed @@ -118,6 +126,26 @@ func getOOMTargetPod(podName string, ctnName string, createContainer func(name s } } +func getInitContainerOOMTargetPod(podName string, ctnName string, createContainer func(name string) v1.Container) *v1.Pod { + return &v1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Name: podName, + }, + Spec: v1.PodSpec{ + RestartPolicy: v1.RestartPolicyNever, + InitContainers: []v1.Container{ + createContainer(ctnName), + }, + Containers: []v1.Container{ + { + Name: "busybox", + Image: busyboxImage, + }, + }, + }, + } +} + // getOOMTargetContainer returns a container with a single process, which attempts to allocate more memory than is // allowed by the container memory limit. func getOOMTargetContainer(name string) v1.Container { diff --git a/test/e2e_node/pods_lifecycle_termination_test.go b/test/e2e_node/pods_lifecycle_termination_test.go index 69976e98896..3dc786c1ee2 100644 --- a/test/e2e_node/pods_lifecycle_termination_test.go +++ b/test/e2e_node/pods_lifecycle_termination_test.go @@ -109,13 +109,13 @@ func getSigkillTargetPod(podName string, ctnName string) *v1.Pod { Image: busyboxImage, // In the main container, SIGTERM was trapped and later /tmp/healthy // will be created for readiness probe to verify if the trap was - // excucuted successfully + // executed successfully Command: []string{ "sh", "-c", "trap \"echo SIGTERM caught\" SIGTERM SIGINT; touch /tmp/healthy; sleep 1000", }, - // Using readinessprobe to guarantee signal handler registering finished + // Using readiness probe to guarantee signal handler registering finished ReadinessProbe: &v1.Probe{ InitialDelaySeconds: 1, TimeoutSeconds: 2,