aboutsummaryrefslogtreecommitdiff
path: root/pkg/systemd/generate/containers.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/systemd/generate/containers.go')
-rw-r--r--pkg/systemd/generate/containers.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/pkg/systemd/generate/containers.go b/pkg/systemd/generate/containers.go
index 6f546b0ab..8510cfd42 100644
--- a/pkg/systemd/generate/containers.go
+++ b/pkg/systemd/generate/containers.go
@@ -148,6 +148,18 @@ func generateContainerInfo(ctr *libpod.Container, options entities.GenerateSyste
return nil, errors.New("conmon PID file path is empty, try to recreate the container with --conmon-pidfile flag")
}
+ // #15284: old units generated without --new can lead to issues on
+ // shutdown when the containers are created with a custom restart
+ // policy.
+ if !options.New {
+ switch config.RestartPolicy {
+ case libpodDefine.RestartPolicyNo, libpodDefine.RestartPolicyNone:
+ // All good
+ default:
+ logrus.Warnf("Container %s has restart policy %q which can lead to issues on shutdown: consider recreating the container without a restart policy and use systemd's restart mechanism instead", ctr.ID(), config.RestartPolicy)
+ }
+ }
+
createCommand := []string{}
if config.CreateCommand != nil {
createCommand = config.CreateCommand
@@ -491,7 +503,7 @@ func executeContainerTemplate(info *containerInfo, options entities.GenerateSyst
// template execution.
templ, err := template.New("container_template").Delims("{{{{", "}}}}").Parse(containerTemplate)
if err != nil {
- return "", fmt.Errorf("error parsing systemd service template: %w", err)
+ return "", fmt.Errorf("parsing systemd service template: %w", err)
}
var buf bytes.Buffer
@@ -502,7 +514,7 @@ func executeContainerTemplate(info *containerInfo, options entities.GenerateSyst
// Now parse the generated template (i.e., buf) and execute it.
templ, err = template.New("container_template").Delims("{{{{", "}}}}").Parse(buf.String())
if err != nil {
- return "", fmt.Errorf("error parsing systemd service template: %w", err)
+ return "", fmt.Errorf("parsing systemd service template: %w", err)
}
buf = bytes.Buffer{}