Skip to content

Commit

Permalink
fix: initContainer restart policy overridden by pod
Browse files Browse the repository at this point in the history
Restart policy of initContainers should not be overriden by pod and
the restart policy should always be "no".

See #16343

Signed-off-by: Tony Duan <[email protected]>
  • Loading branch information
tony84727 committed May 5, 2023
1 parent f4d2d17 commit 5322071
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/specgen/generate/container_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ func createContainerOptions(rt *libpod.Runtime, s *specgen.SpecGenerator, pod *l
retries uint
)
// 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()
if podConfig.RestartRetries != nil {
retries = *podConfig.RestartRetries
Expand Down
4 changes: 4 additions & 0 deletions pkg/specgen/specgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,10 @@ func (s *SpecGenerator) GetImage() (*libimage.Image, string) {
return s.image, s.resolvedImageName
}

func (s *SpecGenerator) IsInitContainer() bool {
return len(s.InitContainerType) != 0
}

type Secret struct {
Source string
Target string
Expand Down

0 comments on commit 5322071

Please sign in to comment.