Skip to content

Commit

Permalink
generate systemd: add network dependencies
Browse files Browse the repository at this point in the history
Add network dependencies to generated systemd services to allow for
enabling them at system startup and have a working network if needed.

Fixes: containers#4130
Signed-off-by: Valentin Rothberg <[email protected]>
  • Loading branch information
vrothberg authored and snj33v committed May 31, 2020
1 parent 90a94d8 commit e247997
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/systemd/generate/systemdgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ const containerTemplate = `# {{.ServiceName}}.service
[Unit]
Description=Podman {{.ServiceName}}.service
Documentation=man:podman-generate-systemd(1)
Wants=network.target
After=network-online.target
{{- if .BoundToServices}}
RefuseManualStart=yes
RefuseManualStop=yes
Expand Down
10 changes: 10 additions & 0 deletions pkg/systemd/generate/systemdgen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ func TestCreateContainerSystemdUnit(t *testing.T) {
[Unit]
Description=Podman container-639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401.service
Documentation=man:podman-generate-systemd(1)
Wants=network.target
After=network-online.target
[Service]
Restart=always
Expand All @@ -58,6 +60,8 @@ WantedBy=multi-user.target`
[Unit]
Description=Podman container-foobar.service
Documentation=man:podman-generate-systemd(1)
Wants=network.target
After=network-online.target
[Service]
Restart=always
Expand All @@ -76,6 +80,8 @@ WantedBy=multi-user.target`
[Unit]
Description=Podman container-foobar.service
Documentation=man:podman-generate-systemd(1)
Wants=network.target
After=network-online.target
RefuseManualStart=yes
RefuseManualStop=yes
BindsTo=a.service b.service c.service pod.service
Expand All @@ -98,6 +104,8 @@ WantedBy=multi-user.target`
[Unit]
Description=Podman pod-123abc.service
Documentation=man:podman-generate-systemd(1)
Wants=network.target
After=network-online.target
Requires=container-1.service container-2.service
Before=container-1.service container-2.service
Expand All @@ -118,6 +126,8 @@ WantedBy=multi-user.target`
[Unit]
Description=Podman jadda-jadda.service
Documentation=man:podman-generate-systemd(1)
Wants=network.target
After=network-online.target
[Service]
Restart=always
Expand Down

0 comments on commit e247997

Please sign in to comment.