Add support for StopSignal in quadlet .container files

Fixes: https://github.com/containers/podman/issues/23050

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh
2024-07-21 06:08:00 -04:00
parent 003527fedc
commit 0ecd6fa59f
4 changed files with 19 additions and 0 deletions

View File

@ -306,6 +306,7 @@ Valid options for `[Container]` are listed below:
| SecurityLabelNested=true | --security-opt label=nested | | SecurityLabelNested=true | --security-opt label=nested |
| SecurityLabelType=spc_t | --security-opt label=type:spc_t | | SecurityLabelType=spc_t | --security-opt label=type:spc_t |
| ShmSize=100m | --shm-size=100m | | ShmSize=100m | --shm-size=100m |
| StopSignal=SIGINT | --stop-signal=SIGINT |
| StopTimeout=20 | --stop-timeout=20 | | StopTimeout=20 | --stop-timeout=20 |
| SubGIDMap=gtest | --subgidname=gtest | | SubGIDMap=gtest | --subgidname=gtest |
| SubUIDMap=utest | --subuidname=utest | | SubUIDMap=utest | --subuidname=utest |
@ -731,6 +732,12 @@ Size of /dev/shm.
This is equivalent to the Podman `--shm-size` option and generally has the form `number[unit]` This is equivalent to the Podman `--shm-size` option and generally has the form `number[unit]`
### `StopSignal=`
Signal to stop a container. Default is **SIGTERM**.
This is equivalent to the Podman `--stop-signal` option
### `StopTimeout=` ### `StopTimeout=`
Seconds to wait before forcibly stopping the container. Seconds to wait before forcibly stopping the container.

View File

@ -143,6 +143,7 @@ const (
KeySecurityLabelType = "SecurityLabelType" KeySecurityLabelType = "SecurityLabelType"
KeySetWorkingDirectory = "SetWorkingDirectory" KeySetWorkingDirectory = "SetWorkingDirectory"
KeyShmSize = "ShmSize" KeyShmSize = "ShmSize"
KeyStopSignal = "StopSignal"
KeyStopTimeout = "StopTimeout" KeyStopTimeout = "StopTimeout"
KeySubGIDMap = "SubGIDMap" KeySubGIDMap = "SubGIDMap"
KeySubnet = "Subnet" KeySubnet = "Subnet"
@ -242,6 +243,7 @@ var (
KeySecurityLabelNested: true, KeySecurityLabelNested: true,
KeySecurityLabelType: true, KeySecurityLabelType: true,
KeyShmSize: true, KeyShmSize: true,
KeyStopSignal: true,
KeyStopTimeout: true, KeyStopTimeout: true,
KeySubGIDMap: true, KeySubGIDMap: true,
KeySubUIDMap: true, KeySubUIDMap: true,
@ -843,6 +845,10 @@ func ConvertContainer(container *parser.UnitFile, names map[string]string, isUse
return nil, err return nil, err
} }
if stopSignal, ok := container.Lookup(ContainerGroup, KeyStopSignal); ok && len(stopSignal) > 0 {
podman.add("--stop-signal", stopSignal)
}
if stopTimeout, ok := container.Lookup(ContainerGroup, KeyStopTimeout); ok && len(stopTimeout) > 0 { if stopTimeout, ok := container.Lookup(ContainerGroup, KeyStopTimeout); ok && len(stopTimeout) > 0 {
podman.add("--stop-timeout", stopTimeout) podman.add("--stop-timeout", stopTimeout)
} }

View File

@ -0,0 +1,5 @@
## assert-podman-args "--stop-signal" "SIGKILL"
[Container]
Image=localhost/imagename
StopSignal=SIGKILL

View File

@ -854,6 +854,7 @@ BOGUS=foo
Entry("selinux.container", "selinux.container", 0, ""), Entry("selinux.container", "selinux.container", 0, ""),
Entry("shmsize.container", "shmsize.container", 0, ""), Entry("shmsize.container", "shmsize.container", 0, ""),
Entry("shortname.container", "shortname.container", 0, "Warning: shortname.container specifies the image \"shortname\" which not a fully qualified image name. This is not ideal for performance and security reasons. See the podman-pull manpage discussion of short-name-aliases.conf for details."), Entry("shortname.container", "shortname.container", 0, "Warning: shortname.container specifies the image \"shortname\" which not a fully qualified image name. This is not ideal for performance and security reasons. See the podman-pull manpage discussion of short-name-aliases.conf for details."),
Entry("stopsigal.container", "stopsignal.container", 0, ""),
Entry("stoptimeout.container", "stoptimeout.container", 0, ""), Entry("stoptimeout.container", "stoptimeout.container", 0, ""),
Entry("subidmapping.container", "subidmapping.container", 0, ""), Entry("subidmapping.container", "subidmapping.container", 0, ""),
Entry("subidmapping-with-remap.container", "subidmapping-with-remap.container", 1, "converting \"subidmapping-with-remap.container\": deprecated Remap keys are set along with explicit mapping keys"), Entry("subidmapping-with-remap.container", "subidmapping-with-remap.container", 1, "converting \"subidmapping-with-remap.container\": deprecated Remap keys are set along with explicit mapping keys"),