Change:
Init container exited with OOMKilled reason, but init container was marked succesful, and main app container was allowed to be started If non init process gets killed the container should not be marked OOMKilled or If OOMKilled is terminate reason main app contaienr should not be started. According to Container should only be marked OOMKilled if init process is killed. the container the When checking init container status: But main app container is running. Kubernetes version (use ): Dockerfile:
According to previous issue will add sig label: /sig node
/assign
I have a quesion. when the oom killer, why your init container exit code is 0. normal is 137.
the init process is the shell script. the oom killer kills the forked process of stress tester, and it continues the script. next step is to exit 0 in the if process. wth error handling this can be caught, but my problem is, if there is a 0 exit code, and init process isnt oom killed, why is there a reason of oomkilled.
when you use shell scripts, you should add . kubelet will collect the status of init container. when init container is oomkilled, the container status will save the oom kill message.
I understand that. but according to the behaviour that is written, this is not expected outcome. The init container was not killed because of oom, just a single process. There should be 2 expected behaviours: Either there should be no printed, since it should only be when the main init process gets killed Or the whole init container should fail if any process is caught with oom.
I think you are right.
/assign
/triage accepted

Discussion:
return new(int64), "", nil } <del> // isInitContainerFailed returns true if container has exited and exitcode is not zero // or is in unknown state. </del> <ins> // isInitContainerFailed returns true under the following conditions: // 1. container has exited and exitcode is not zero. // 2. container is in unknown state. // 3. container gets OOMKilled. </ins> func isInitContainerFailed(status *kubecontainer.Status) bool { <ins> // When oomkilled occurs, init container should be considered as a failure. if status.Reason == "OOMKilled" { return true } </ins> if status.State == kubecontainer.ContainerStateExited && status.ExitCode != 0 { return true }

return "localhost/" + seccompLocalhostRef(profileName) } <ins> func TestIsInitContainerFailed(t *testing.T) { tests := []struct { status      *kubecontainer.Status isFailed    bool description string }{ { status: &kubecontainer.Status{ State:    kubecontainer.ContainerStateExited, ExitCode: 1, }, isFailed:    true, description: "Init container in exited state and non-zero exit code should return true", }, { status: &kubecontainer.Status{ State: kubecontainer.ContainerStateUnknown, }, isFailed:    true, description: "Init container in unknown state should return true", }, { status: &kubecontainer.Status{ Reason:   "OOMKilled", ExitCode: 0, }, isFailed:    true, description: "Init container which reason is OOMKilled should return true", }, { status: &kubecontainer.Status{ State:    kubecontainer.ContainerStateExited, ExitCode: 0, }, isFailed:    false, description: "Init container in exited state and zero exit code should return false", }, { status: &kubecontainer.Status{ State: kubecontainer.ContainerStateRunning, }, isFailed:    false, description: "Init container in running state should return false", }, { status: &kubecontainer.Status{ State: kubecontainer.ContainerStateCreated, }, isFailed:    false, description: "Init container in created state should return false", }, } for i, test := range tests { isFailed := isInitContainerFailed(test.status) assert.Equal(t, test.isFailed, isFailed, "TestCase[%d]: %s", i, test.description) } } </ins> func TestStableKey(t *testing.T) { container := &v1.Container{ Name:  "test_container",