summaryrefslogtreecommitdiff
path: root/pkg/systemd/generate/pods.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-06-15 12:54:36 -0400
committerGitHub <noreply@github.com>2020-06-15 12:54:36 -0400
commit10c6c806ea6d7830c248d9c89cd5ec3a7a515a63 (patch)
tree837474da079889daa027b66e5239915dd983f7ab /pkg/systemd/generate/pods.go
parentb89729778c253f0eccd2dd762e5d0a6547aaea7d (diff)
parent6118ab494884eea62c388fa1536349f05cdac9d3 (diff)
downloadpodman-10c6c806ea6d7830c248d9c89cd5ec3a7a515a63.tar.gz
podman-10c6c806ea6d7830c248d9c89cd5ec3a7a515a63.tar.bz2
podman-10c6c806ea6d7830c248d9c89cd5ec3a7a515a63.zip
Merge pull request #6553 from vrothberg/replace
--replace for containers and pods
Diffstat (limited to 'pkg/systemd/generate/pods.go')
-rw-r--r--pkg/systemd/generate/pods.go17
1 files changed, 16 insertions, 1 deletions
diff --git a/pkg/systemd/generate/pods.go b/pkg/systemd/generate/pods.go
index 5cfd5ab0a..367b8381f 100644
--- a/pkg/systemd/generate/pods.go
+++ b/pkg/systemd/generate/pods.go
@@ -265,7 +265,7 @@ func executePodTemplate(info *podInfo, options entities.GenerateSystemdOptions)
if podCreateIndex == 0 {
return "", errors.Errorf("pod does not appear to be created via `podman pod create`: %v", info.CreateCommand)
}
- podRootArgs = info.CreateCommand[1 : podCreateIndex-2]
+ podRootArgs = info.CreateCommand[0 : podCreateIndex-2]
podCreateArgs = filterPodFlags(info.CreateCommand[podCreateIndex+1:])
}
// We're hard-coding the first five arguments and append the
@@ -277,6 +277,21 @@ func executePodTemplate(info *podInfo, options entities.GenerateSystemdOptions)
"--infra-conmon-pidfile", "{{.PIDFile}}",
"--pod-id-file", "{{.PodIDFile}}"}...)
+ // Presence check for certain flags/options.
+ hasNameParam := false
+ hasReplaceParam := false
+ for _, p := range podCreateArgs {
+ switch p {
+ case "--name":
+ hasNameParam = true
+ case "--replace":
+ hasReplaceParam = true
+ }
+ }
+ if hasNameParam && !hasReplaceParam {
+ podCreateArgs = append(podCreateArgs, "--replace")
+ }
+
startCommand = append(startCommand, podCreateArgs...)
info.ExecStartPre1 = "/usr/bin/rm -f {{.PIDFile}} {{.PodIDFile}}"