summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2021-04-22 15:38:36 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2021-04-23 11:18:05 -0400
commit3538815c5b2b4c97304e3ea940cee414b0004d2f (patch)
treea307b133a805e47633882d2f42e65105d903b247 /pkg
parentba60821f0aadef99f200fa708b26fb9921ed7b70 (diff)
downloadpodman-3538815c5b2b4c97304e3ea940cee414b0004d2f.tar.gz
podman-3538815c5b2b4c97304e3ea940cee414b0004d2f.tar.bz2
podman-3538815c5b2b4c97304e3ea940cee414b0004d2f.zip
Add podman run --timeout option
This option allows users to specify the maximum amount of time to run before conmon sends the kill signal to the container. Fixes: https://github.com/containers/podman/issues/6412 Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/specgen/generate/container_create.go3
-rw-r--r--pkg/specgen/specgen.go5
2 files changed, 8 insertions, 0 deletions
diff --git a/pkg/specgen/generate/container_create.go b/pkg/specgen/generate/container_create.go
index 13d4b4926..700f582db 100644
--- a/pkg/specgen/generate/container_create.go
+++ b/pkg/specgen/generate/container_create.go
@@ -292,6 +292,9 @@ func createContainerOptions(ctx context.Context, rt *libpod.Runtime, s *specgen.
if s.StopTimeout != nil {
options = append(options, libpod.WithStopTimeout(*s.StopTimeout))
}
+ if s.Timeout != 0 {
+ options = append(options, libpod.WithTimeout(s.Timeout))
+ }
if s.LogConfiguration != nil {
if len(s.LogConfiguration.Path) > 0 {
options = append(options, libpod.WithLogPath(s.LogConfiguration.Path))
diff --git a/pkg/specgen/specgen.go b/pkg/specgen/specgen.go
index e3d4b1436..fdcb7a0e0 100644
--- a/pkg/specgen/specgen.go
+++ b/pkg/specgen/specgen.go
@@ -83,6 +83,11 @@ type ContainerBasicConfig struct {
// instead.
// Optional.
StopTimeout *uint `json:"stop_timeout,omitempty"`
+ // Timeout is a maximum time in seconds the container will run before
+ // main process is sent SIGKILL.
+ // If 0 is used, signal will not be sent. Container can run indefinitely
+ // Optional.
+ Timeout uint `json:"timeout,omitempty"`
// LogConfiguration describes the logging for a container including
// driver, path, and options.
// Optional