Skip to content

Commit

Permalink
systemd: require network*-online*.target
Browse files Browse the repository at this point in the history
Require the network to be online in all (generated) systemd units to
make sure that containers and Podman run only after the network has been
fully configured.

Fixes: containers#10655
Signed-off-by: Valentin Rothberg <[email protected]>
  • Loading branch information
vrothberg committed Jul 16, 2021
1 parent ce28dc3 commit 6f1c7a0
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion contrib/systemd/auto-update/podman-auto-update.service
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[Unit]
Description=Podman auto-update service
Documentation=man:podman-auto-update(1)
Wants=network.target
Wants=network-online.target
After=network-online.target

[Service]
Expand Down
6 changes: 3 additions & 3 deletions docs/source/markdown/podman-generate-systemd.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ $ podman generate systemd --restart-policy=always -t 1 nginx
[Unit]
Description=Podman container-de1e3223b1b888bc02d0962dd6cb5855eb00734061013ffdd3479d225abacdc6.service
Documentation=man:podman-generate-systemd(1)
Wants=network.target
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/container/storage
Expand Down Expand Up @@ -102,7 +102,7 @@ $ sudo podman generate systemd --new --files --name bb310a0780ae
[Unit]
Description=Podman container-busy_moser.service
Documentation=man:podman-generate-systemd(1)
Wants=network.target
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/container/storage
Expand Down Expand Up @@ -144,7 +144,7 @@ Description=Podman pod-systemd-pod.service
Documentation=man:podman-generate-systemd(1)
Requires=container-amazing_chandrasekhar.service container-jolly_shtern.service
Before=container-amazing_chandrasekhar.service container-jolly_shtern.service
Wants=network.target
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/container/storage
Expand Down
2 changes: 1 addition & 1 deletion pkg/systemd/generate/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const headerTemplate = `# {{{{.ServiceName}}}}.service
[Unit]
Description=Podman {{{{.ServiceName}}}}.service
Documentation=man:podman-generate-systemd(1)
Wants=network.target
Wants=network-online.target
After=network-online.target
RequiresMountsFor={{{{.RunRoot}}}}
`
Expand Down
34 changes: 17 additions & 17 deletions pkg/systemd/generate/containers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestCreateContainerSystemdUnit(t *testing.T) {
[Unit]
Description=Podman container-639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401.service
Documentation=man:podman-generate-systemd(1)
Wants=network.target
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/containers/storage
Expand All @@ -72,7 +72,7 @@ WantedBy=multi-user.target default.target
[Unit]
Description=Podman container-foobar.service
Documentation=man:podman-generate-systemd(1)
Wants=network.target
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/containers/storage
Expand All @@ -96,7 +96,7 @@ WantedBy=multi-user.target default.target
[Unit]
Description=Podman container-foobar.service
Documentation=man:podman-generate-systemd(1)
Wants=network.target
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/containers/storage
BindsTo=a.service b.service c.service pod.service
Expand All @@ -122,7 +122,7 @@ WantedBy=multi-user.target default.target
[Unit]
Description=Podman jadda-jadda.service
Documentation=man:podman-generate-systemd(1)
Wants=network.target
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/containers/storage
Expand All @@ -144,7 +144,7 @@ WantedBy=multi-user.target default.target
[Unit]
Description=Podman jadda-jadda.service
Documentation=man:podman-generate-systemd(1)
Wants=network.target
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/containers/storage
Expand All @@ -166,7 +166,7 @@ WantedBy=multi-user.target default.target
[Unit]
Description=Podman jadda-jadda.service
Documentation=man:podman-generate-systemd(1)
Wants=network.target
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/containers/storage
Expand All @@ -188,7 +188,7 @@ WantedBy=multi-user.target default.target
[Unit]
Description=Podman jadda-jadda.service
Documentation=man:podman-generate-systemd(1)
Wants=network.target
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/containers/storage
Expand All @@ -210,7 +210,7 @@ WantedBy=multi-user.target default.target
[Unit]
Description=Podman container-639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401.service
Documentation=man:podman-generate-systemd(1)
Wants=network.target
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/containers/storage
Expand All @@ -233,7 +233,7 @@ WantedBy=multi-user.target default.target
[Unit]
Description=Podman jadda-jadda.service
Documentation=man:podman-generate-systemd(1)
Wants=network.target
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/containers/storage
Expand All @@ -259,7 +259,7 @@ WantedBy=multi-user.target default.target
[Unit]
Description=Podman jadda-jadda.service
Documentation=man:podman-generate-systemd(1)
Wants=network.target
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/containers/storage
Expand All @@ -281,7 +281,7 @@ WantedBy=multi-user.target default.target
[Unit]
Description=Podman jadda-jadda.service
Documentation=man:podman-generate-systemd(1)
Wants=network.target
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/containers/storage
Expand All @@ -303,7 +303,7 @@ WantedBy=multi-user.target default.target
[Unit]
Description=Podman jadda-jadda.service
Documentation=man:podman-generate-systemd(1)
Wants=network.target
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/containers/storage
Expand All @@ -325,7 +325,7 @@ WantedBy=multi-user.target default.target
[Unit]
Description=Podman jadda-jadda.service
Documentation=man:podman-generate-systemd(1)
Wants=network.target
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/containers/storage
Expand All @@ -347,7 +347,7 @@ WantedBy=multi-user.target default.target
[Unit]
Description=Podman jadda-jadda.service
Documentation=man:podman-generate-systemd(1)
Wants=network.target
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/containers/storage
Expand All @@ -369,7 +369,7 @@ WantedBy=multi-user.target default.target
[Unit]
Description=Podman jadda-jadda.service
Documentation=man:podman-generate-systemd(1)
Wants=network.target
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/containers/storage
Expand All @@ -391,7 +391,7 @@ WantedBy=multi-user.target default.target
[Unit]
Description=Podman jadda-jadda.service
Documentation=man:podman-generate-systemd(1)
Wants=network.target
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/containers/storage
Expand All @@ -413,7 +413,7 @@ WantedBy=multi-user.target default.target
[Unit]
Description=Podman jadda-jadda.service
Documentation=man:podman-generate-systemd(1)
Wants=network.target
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/containers/storage
Expand Down
10 changes: 5 additions & 5 deletions pkg/systemd/generate/pods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestCreatePodSystemdUnit(t *testing.T) {
[Unit]
Description=Podman pod-123abc.service
Documentation=man:podman-generate-systemd(1)
Wants=network.target
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/containers/storage
Requires=container-1.service container-2.service
Expand Down Expand Up @@ -73,7 +73,7 @@ WantedBy=multi-user.target default.target
[Unit]
Description=Podman pod-123abc.service
Documentation=man:podman-generate-systemd(1)
Wants=network.target
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/containers/storage
Requires=container-1.service container-2.service
Expand Down Expand Up @@ -101,7 +101,7 @@ WantedBy=multi-user.target default.target
[Unit]
Description=Podman pod-123abc.service
Documentation=man:podman-generate-systemd(1)
Wants=network.target
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/containers/storage
Requires=container-1.service container-2.service
Expand Down Expand Up @@ -129,7 +129,7 @@ WantedBy=multi-user.target default.target
[Unit]
Description=Podman pod-123abc.service
Documentation=man:podman-generate-systemd(1)
Wants=network.target
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/containers/storage
Requires=container-1.service container-2.service
Expand Down Expand Up @@ -157,7 +157,7 @@ WantedBy=multi-user.target default.target
[Unit]
Description=Podman pod-123abc.service
Documentation=man:podman-generate-systemd(1)
Wants=network.target
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/containers/storage
Requires=container-1.service container-2.service
Expand Down
2 changes: 1 addition & 1 deletion test/system/255-auto-update.bats
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ EOF
[Unit]
Description=Podman auto-update testing service
Documentation=man:podman-auto-update(1)
Wants=network.target
Wants=network-online.target
After=network-online.target
[Service]
Expand Down

0 comments on commit 6f1c7a0

Please sign in to comment.