mirror of
https://github.com/containers/podman.git
synced 2025-08-06 19:44:14 +08:00
Merge pull request #18481 from tony84727/fix/initctr-restart-policy-overridden
fix: initContainer restart policy overridden by pod
This commit is contained in:
@ -560,7 +560,7 @@ func createContainerOptions(rt *libpod.Runtime, s *specgen.SpecGenerator, pod *l
|
|||||||
retries uint
|
retries uint
|
||||||
)
|
)
|
||||||
// If the container is running in a pod, use the pod's restart policy for all the containers
|
// If the container is running in a pod, use the pod's restart policy for all the containers
|
||||||
if pod != nil {
|
if pod != nil && !s.IsInitContainer() {
|
||||||
podConfig := pod.ConfigNoCopy()
|
podConfig := pod.ConfigNoCopy()
|
||||||
if podConfig.RestartRetries != nil {
|
if podConfig.RestartRetries != nil {
|
||||||
retries = *podConfig.RestartRetries
|
retries = *podConfig.RestartRetries
|
||||||
|
@ -586,6 +586,10 @@ func (s *SpecGenerator) GetImage() (*libimage.Image, string) {
|
|||||||
return s.image, s.resolvedImageName
|
return s.image, s.resolvedImageName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *SpecGenerator) IsInitContainer() bool {
|
||||||
|
return len(s.InitContainerType) != 0
|
||||||
|
}
|
||||||
|
|
||||||
type Secret struct {
|
type Secret struct {
|
||||||
Source string
|
Source string
|
||||||
Target string
|
Target string
|
||||||
|
@ -2234,6 +2234,12 @@ var _ = Describe("Podman play kube", func() {
|
|||||||
Expect(inspect).Should(Exit(0))
|
Expect(inspect).Should(Exit(0))
|
||||||
Expect(inspect.OutputToString()).To(ContainSubstring("running"))
|
Expect(inspect.OutputToString()).To(ContainSubstring("running"))
|
||||||
|
|
||||||
|
// Init containers should not be restarted
|
||||||
|
inspect = podmanTest.Podman([]string{"inspect", "--format", "{{ .HostConfig.RestartPolicy.Name }}", "testPod-" + defaultCtrName})
|
||||||
|
inspect.WaitWithDefaultTimeout()
|
||||||
|
Expect(inspect).Should(Exit(0))
|
||||||
|
Expect(inspect.OutputToString()).To(ContainSubstring(define.RestartPolicyNo))
|
||||||
|
|
||||||
// Init containers need environment too! #18384
|
// Init containers need environment too! #18384
|
||||||
logs := podmanTest.Podman([]string{"logs", "testPod-init-test"})
|
logs := podmanTest.Podman([]string{"logs", "testPod-init-test"})
|
||||||
logs.WaitWithDefaultTimeout()
|
logs.WaitWithDefaultTimeout()
|
||||||
|
Reference in New Issue
Block a user