summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorValentin Rothberg <vrothberg@redhat.com>2022-09-13 16:26:59 +0200
committerValentin Rothberg <vrothberg@redhat.com>2022-09-13 17:25:48 +0200
commitfe04c86a242f1c61d8f5e0afdc8aa84851265550 (patch)
treef427da90617fe35d79802bf7003fca634737b60a /pkg
parent1b3e8639f3a9041dcbc26b22b9c244a679075734 (diff)
downloadpodman-fe04c86a242f1c61d8f5e0afdc8aa84851265550.tar.gz
podman-fe04c86a242f1c61d8f5e0afdc8aa84851265550.tar.bz2
podman-fe04c86a242f1c61d8f5e0afdc8aa84851265550.zip
generate systemd: fix pod dependencies
Change the dependencies from a pod unit to its associated container units from `Requires` to `Wants` to prevent the entire pod from transitioning to a failed state. Restart policies for individual containers can be configured separately. Also make sure that the pod's RunRoot is always set. Fixes: #14546 Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/systemd/generate/pods.go3
-rw-r--r--pkg/systemd/generate/pods_test.go22
2 files changed, 13 insertions, 12 deletions
diff --git a/pkg/systemd/generate/pods.go b/pkg/systemd/generate/pods.go
index 22f568220..0ff3b8b7b 100644
--- a/pkg/systemd/generate/pods.go
+++ b/pkg/systemd/generate/pods.go
@@ -92,7 +92,7 @@ type podInfo struct {
Requires []string
}
-const podTemplate = headerTemplate + `Requires={{{{- range $index, $value := .RequiredServices -}}}}{{{{if $index}}}} {{{{end}}}}{{{{ $value }}}}.service{{{{end}}}}
+const podTemplate = headerTemplate + `Wants={{{{- range $index, $value := .RequiredServices -}}}}{{{{if $index}}}} {{{{end}}}}{{{{ $value }}}}.service{{{{end}}}}
Before={{{{- range $index, $value := .RequiredServices -}}}}{{{{if $index}}}} {{{{end}}}}{{{{ $value }}}}.service{{{{end}}}}
{{{{- if or .Wants .After .Requires }}}}
@@ -252,6 +252,7 @@ func generatePodInfo(pod *libpod.Pod, options entities.GenerateSystemdOptions) (
StopTimeout: stopTimeout,
GenerateTimestamp: true,
CreateCommand: createCommand,
+ RunRoot: infraCtr.Runtime().RunRoot(),
}
return &info, nil
}
diff --git a/pkg/systemd/generate/pods_test.go b/pkg/systemd/generate/pods_test.go
index 59f217256..d50fa9f48 100644
--- a/pkg/systemd/generate/pods_test.go
+++ b/pkg/systemd/generate/pods_test.go
@@ -70,7 +70,7 @@ Documentation=man:podman-generate-systemd(1)
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/containers/storage
-Requires=container-1.service container-2.service
+Wants=container-1.service container-2.service
Before=container-1.service container-2.service
[Service]
@@ -98,7 +98,7 @@ Documentation=man:podman-generate-systemd(1)
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/containers/storage
-Requires=container-1.service container-2.service
+Wants=container-1.service container-2.service
Before=container-1.service container-2.service
[Service]
@@ -124,7 +124,7 @@ Documentation=man:podman-generate-systemd(1)
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/containers/storage
-Requires=container-1.service container-2.service
+Wants=container-1.service container-2.service
Before=container-1.service container-2.service
# User-defined dependencies
@@ -152,7 +152,7 @@ Documentation=man:podman-generate-systemd(1)
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/containers/storage
-Requires=container-1.service container-2.service
+Wants=container-1.service container-2.service
Before=container-1.service container-2.service
# User-defined dependencies
@@ -180,7 +180,7 @@ Documentation=man:podman-generate-systemd(1)
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/containers/storage
-Requires=container-1.service container-2.service
+Wants=container-1.service container-2.service
Before=container-1.service container-2.service
# User-defined dependencies
@@ -208,7 +208,7 @@ Documentation=man:podman-generate-systemd(1)
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/containers/storage
-Requires=container-1.service container-2.service
+Wants=container-1.service container-2.service
Before=container-1.service container-2.service
# User-defined dependencies
@@ -239,7 +239,7 @@ Documentation=man:podman-generate-systemd(1)
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/containers/storage
-Requires=container-1.service container-2.service
+Wants=container-1.service container-2.service
Before=container-1.service container-2.service
[Service]
@@ -266,7 +266,7 @@ Documentation=man:podman-generate-systemd(1)
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/containers/storage
-Requires=container-1.service container-2.service
+Wants=container-1.service container-2.service
Before=container-1.service container-2.service
[Service]
@@ -294,7 +294,7 @@ Documentation=man:podman-generate-systemd(1)
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/containers/storage
-Requires=container-1.service container-2.service
+Wants=container-1.service container-2.service
Before=container-1.service container-2.service
[Service]
@@ -322,7 +322,7 @@ Documentation=man:podman-generate-systemd(1)
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/containers/storage
-Requires=container-1.service container-2.service
+Wants=container-1.service container-2.service
Before=container-1.service container-2.service
[Service]
@@ -350,7 +350,7 @@ Documentation=man:podman-generate-systemd(1)
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/containers/storage
-Requires=container-1.service container-2.service
+Wants=container-1.service container-2.service
Before=container-1.service container-2.service
[Service]