-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
fix: initContainer restart policy overridden by pod #18481
fix: initContainer restart policy overridden by pod #18481
Conversation
Restart policy of initContainers should not be overriden by pod and the restart policy should always be "no". See containers#16343 Signed-off-by: Tony Duan <[email protected]>
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@umohnani8 PTAL
Let's make sure to have similar checks for service and infra containers as well.
@tony84727 would you like to convert this into a PR and add a check for service container as well? If not, I can take over |
@umohnani8 I was planning to add some test, at least for initContainers. Feel free to take over, though. |
Added a e2e test case for init containers, converting this to an PR. |
419ece6
to
6861158
Compare
test/e2e/pod_initcontainers_test.go
Outdated
checkRestartPolicy := podmanTest.Podman([]string{"inspect", initContainerName, "--format", "{{ .HostConfig.RestartPolicy.Name }}"}) | ||
checkRestartPolicy.WaitWithDefaultTimeout() | ||
Expect(checkRestartPolicy).Should(gbytes.Say(define.RestartPolicyNo)) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test failed in my local environment. It might means init containers added by podman create --init-ctr
doesn't have a restart policy name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, looks like restart policy is not added to an init container even when the --restart
flag is set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this test. So that, this PR only fix and test restart policy of init container created by podman kube play
. Is it okay to handle this in another PR or issue?
Based on https://kubernetes.io/docs/concepts/workloads/pods/init-containers/#:~:text=If%20a%20Pod's%20init%20container,the%20overall%20Pod%20as%20failed., init containers should have a restart policy of |
Agree. so basically, the restart policy of an init container is inferred from the restart policy of the pod and users are not allowed to modify or override (i.e. through
|
All this policy discussion is way over my head, but I'd just like to chime in and say that this PR fixes #18477 so I'd like to see it proceed. |
Maybe I can just remove the failing test and keep restart policy of init containers (created by I'm wondering if there's a spec to follow, regarding to the proper behavior of various restart policies. Or we just look at kubernetes' implementation? |
Yes this looks correct. For the most part, we are following k8s conventions for restart policies. There are currently some minor differences, because we don't want to break existing podman behavior. |
make the sure restart policy is "no" for init containers created by `podman kube play` Signed-off-by: Tony Duan <[email protected]>
6861158
to
74a5b92
Compare
@mheon this one is saying a release note is needed, but it looks like there is one already? |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: rhatdan, tony84727 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/cherry-pick v4.5 |
@vrothberg: #18481 failed to apply on top of branch "v4.5":
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Using
main
branch version: f4d2d17.Restart policy of initContainers are overriden by restart policy of the pod.
Reproduce steps:
podman kube play
and the following manifest,podman kube play pod.yaml
pod.yaml
first
will start a nginx daemon and will not exit,podman kube play
will hang (as expected)podman inspect test-first --format '{{ .HostConfig.RestartPolicy.Name }}'
no
butalways
insteadDoes this PR introduce a user-facing change?
Todo