summaryrefslogtreecommitdiff
path: root/pkg/systemd/generate/containers.go
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2021-11-22 11:05:59 +0100
committerValentin Rothberg <rothberg@redhat.com>2021-11-23 09:38:51 +0100
commit566b78dd02e91f376e9f219cb96ddba153671eb5 (patch)
tree02e30c7c2fc1e2726579ee1f5d8fc9e38fea40f2 /pkg/systemd/generate/containers.go
parent1bfbb28b0365790552483b961b4bd48a69dd8070 (diff)
downloadpodman-566b78dd02e91f376e9f219cb96ddba153671eb5.tar.gz
podman-566b78dd02e91f376e9f219cb96ddba153671eb5.tar.bz2
podman-566b78dd02e91f376e9f219cb96ddba153671eb5.zip
generate systemd: add --start-timeout flag
Add a new flag to set the start timeout for a generated systemd unit. To make naming consistent, add a new --stop-timeout flag as well and let the previous --time map to it. Fixes: #11618 Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'pkg/systemd/generate/containers.go')
-rw-r--r--pkg/systemd/generate/containers.go17
1 files changed, 14 insertions, 3 deletions
diff --git a/pkg/systemd/generate/containers.go b/pkg/systemd/generate/containers.go
index 95ff13371..2fdec5fb1 100644
--- a/pkg/systemd/generate/containers.go
+++ b/pkg/systemd/generate/containers.go
@@ -73,6 +73,8 @@ type containerInfo struct {
ExecStartPre string
// ExecStart of the unit.
ExecStart string
+ // TimeoutStartSec of the unit.
+ TimeoutStartSec uint
// TimeoutStopSec of the unit.
TimeoutStopSec uint
// ExecStop of the unit.
@@ -109,6 +111,9 @@ Restart={{{{.RestartPolicy}}}}
{{{{- if .StartLimitBurst}}}}
StartLimitBurst={{{{.StartLimitBurst}}}}
{{{{- end}}}}
+{{{{- if ne .TimeoutStartSec 0}}}}
+TimeoutStartSec={{{{.TimeoutStartSec}}}}
+{{{{- end}}}}
TimeoutStopSec={{{{.TimeoutStopSec}}}}
{{{{- if .ExecStartPre}}}}
ExecStartPre={{{{.ExecStartPre}}}}
@@ -148,9 +153,14 @@ func ContainerUnit(ctr *libpod.Container, options entities.GenerateSystemdOption
}
func generateContainerInfo(ctr *libpod.Container, options entities.GenerateSystemdOptions) (*containerInfo, error) {
- timeout := ctr.StopTimeout()
+ stopTimeout := ctr.StopTimeout()
if options.StopTimeout != nil {
- timeout = *options.StopTimeout
+ stopTimeout = *options.StopTimeout
+ }
+
+ startTimeout := uint(0)
+ if options.StartTimeout != nil {
+ startTimeout = *options.StartTimeout
}
config := ctr.Config()
@@ -185,7 +195,8 @@ func generateContainerInfo(ctr *libpod.Container, options entities.GenerateSyste
ContainerNameOrID: nameOrID,
RestartPolicy: define.DefaultRestartPolicy,
PIDFile: conmonPidFile,
- StopTimeout: timeout,
+ TimeoutStartSec: startTimeout,
+ StopTimeout: stopTimeout,
GenerateTimestamp: true,
CreateCommand: createCommand,
RunRoot: runRoot,