Skip to content

Commit

Permalink
generate systemd pods: generate units with WantedBy=multi-user.target
Browse files Browse the repository at this point in the history
... instead of default.target.

According to the systemd manual[1] "typical" units should not use
`WantedBy=default.target`:

> For typical unit files please set "WantedBy=" to a regular target
> (like multi-user.target or graphical.target),
> instead of default.target, since such a service will also be run on
> special boots like on system update, emergency boot…

Use `multi-user.target` instead.

[1]: https://www.freedesktop.org/software/systemd/man/latest/systemd.special.html#default.target

Signed-off-by: Leonard Göhrs <[email protected]>

Signed-off-by: Leonard Göhrs <[email protected]>
  • Loading branch information
hnez committed Nov 11, 2024
1 parent 0b2b73d commit 78396ce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pkg/systemd/generate/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ PIDFile={{{{.PIDFile}}}}
Type=forking
[Install]
WantedBy=default.target
WantedBy=multi-user.target
`

// PodUnits generates systemd units for the specified pod and its containers.
Expand Down
24 changes: 12 additions & 12 deletions pkg/systemd/generate/pods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ PIDFile=/run/containers/storage/overlay-containers/639c53578af4d84b8800b4635fa4e
Type=forking
[Install]
WantedBy=default.target
WantedBy=multi-user.target
`
podGood := serviceInfo + headerInfo + podContent
podGoodNoHeaderInfo := serviceInfo + podContent
Expand Down Expand Up @@ -119,7 +119,7 @@ PIDFile=/run/containers/storage/overlay-containers/639c53578af4d84b8800b4635fa4e
Type=forking
[Install]
WantedBy=default.target
WantedBy=multi-user.target
`

podGoodCustomWants := `# pod-123abc.service
Expand Down Expand Up @@ -150,7 +150,7 @@ PIDFile=/run/containers/storage/overlay-containers/639c53578af4d84b8800b4635fa4e
Type=forking
[Install]
WantedBy=default.target
WantedBy=multi-user.target
`
podGoodCustomAfter := `# pod-123abc.service
# autogenerated by Podman CI
Expand Down Expand Up @@ -180,7 +180,7 @@ PIDFile=/run/containers/storage/overlay-containers/639c53578af4d84b8800b4635fa4e
Type=forking
[Install]
WantedBy=default.target
WantedBy=multi-user.target
`
podGoodCustomRequires := `# pod-123abc.service
# autogenerated by Podman CI
Expand Down Expand Up @@ -210,7 +210,7 @@ PIDFile=/run/containers/storage/overlay-containers/639c53578af4d84b8800b4635fa4e
Type=forking
[Install]
WantedBy=default.target
WantedBy=multi-user.target
`
podGoodCustomDependencies := `# pod-123abc.service
# autogenerated by Podman CI
Expand Down Expand Up @@ -242,7 +242,7 @@ PIDFile=/run/containers/storage/overlay-containers/639c53578af4d84b8800b4635fa4e
Type=forking
[Install]
WantedBy=default.target
WantedBy=multi-user.target
`
podNoExplicitName := `# pod-123abc.service
# autogenerated by Podman CI
Expand Down Expand Up @@ -278,7 +278,7 @@ PIDFile=%t/pod-123abc.pid
Type=forking
[Install]
WantedBy=default.target
WantedBy=multi-user.target
`

podGoodRestartSec := `# pod-123abc.service
Expand Down Expand Up @@ -307,7 +307,7 @@ PIDFile=/run/containers/storage/overlay-containers/639c53578af4d84b8800b4635fa4e
Type=forking
[Install]
WantedBy=default.target
WantedBy=multi-user.target
`

podGoodNamedNew := `# pod-123abc.service
Expand Down Expand Up @@ -346,7 +346,7 @@ PIDFile=%t/pod-123abc.pid
Type=forking
[Install]
WantedBy=default.target
WantedBy=multi-user.target
`

podGoodNamedNewWithRootArgs := `# pod-123abc.service
Expand Down Expand Up @@ -387,7 +387,7 @@ PIDFile=%t/pod-123abc.pid
Type=forking
[Install]
WantedBy=default.target
WantedBy=multi-user.target
`

podGoodNamedNewWithReplaceFalse := `# pod-123abc.service
Expand Down Expand Up @@ -426,7 +426,7 @@ PIDFile=%t/pod-123abc.pid
Type=forking
[Install]
WantedBy=default.target
WantedBy=multi-user.target
`

podNewLabelWithCurlyBraces := `# pod-123abc.service
Expand Down Expand Up @@ -466,7 +466,7 @@ PIDFile=%t/pod-123abc.pid
Type=forking
[Install]
WantedBy=default.target
WantedBy=multi-user.target
`

tests := []struct {
Expand Down

0 comments on commit 78396ce

Please sign in to comment.