Merge pull request #19955 from rhatdan/quadlet

Add support for PidsLimit in quadlet
This commit is contained in:
OpenShift Merge Robot
2023-09-14 11:48:03 +02:00
committed by GitHub
3 changed files with 25 additions and 6 deletions

View File

@ -160,6 +160,7 @@ Valid options for `[Container]` are listed below:
| NoNewPrivileges=true | --security-opt no-new-privileges | | NoNewPrivileges=true | --security-opt no-new-privileges |
| Rootfs=/var/lib/rootfs | --rootfs /var/lib/rootfs | | Rootfs=/var/lib/rootfs | --rootfs /var/lib/rootfs |
| Notify=true | --sdnotify container | | Notify=true | --sdnotify container |
| PidsLimit=10000 | --pids-limit 10000 |
| PodmanArgs=--add-host foobar | --add-host foobar | | PodmanArgs=--add-host foobar | --add-host foobar |
| PublishPort=50-59 | --publish 50-59 | | PublishPort=50-59 | --publish 50-59 |
| Pull=never | --pull=never | | Pull=never | --pull=never |
@ -431,6 +432,11 @@ starts the child in the container. However, if the container application support
`Notify` to true passes the notification details to the container allowing it to notify `Notify` to true passes the notification details to the container allowing it to notify
of startup on its own. of startup on its own.
### `PidsLimit=`
Tune the container's pids limit.
This is equivalent to the Podman `--pids-limit` option.
### `PodmanArgs=` ### `PodmanArgs=`
This key contains a list of arguments passed directly to the end of the `podman run` command This key contains a list of arguments passed directly to the end of the `podman run` command

View File

@ -94,6 +94,7 @@ const (
KeyNoNewPrivileges = "NoNewPrivileges" KeyNoNewPrivileges = "NoNewPrivileges"
KeyNotify = "Notify" KeyNotify = "Notify"
KeyOptions = "Options" KeyOptions = "Options"
KeyPidsLimit = "PidsLimit"
KeyPodmanArgs = "PodmanArgs" KeyPodmanArgs = "PodmanArgs"
KeyPublishPort = "PublishPort" KeyPublishPort = "PublishPort"
KeyPull = "Pull" KeyPull = "Pull"
@ -169,6 +170,7 @@ var (
KeyNetwork: true, KeyNetwork: true,
KeyNoNewPrivileges: true, KeyNoNewPrivileges: true,
KeyNotify: true, KeyNotify: true,
KeyPidsLimit: true,
KeyPodmanArgs: true, KeyPodmanArgs: true,
KeyPublishPort: true, KeyPublishPort: true,
KeyPull: true, KeyPull: true,
@ -456,18 +458,23 @@ func ConvertContainer(container *parser.UnitFile, names map[string]string, isUse
podman.add("--security-opt", "label:nested") podman.add("--security-opt", "label:nested")
} }
securityLabelType, _ := container.Lookup(ContainerGroup, KeySecurityLabelType) pidsLimit, ok := container.Lookup(ContainerGroup, KeyPidsLimit)
if len(securityLabelType) > 0 { if ok && len(pidsLimit) > 0 {
podman.add("--pids-limit", pidsLimit)
}
securityLabelType, ok := container.Lookup(ContainerGroup, KeySecurityLabelType)
if ok && len(securityLabelType) > 0 {
podman.add("--security-opt", fmt.Sprintf("label=type:%s", securityLabelType)) podman.add("--security-opt", fmt.Sprintf("label=type:%s", securityLabelType))
} }
securityLabelFileType, _ := container.Lookup(ContainerGroup, KeySecurityLabelFileType) securityLabelFileType, ok := container.Lookup(ContainerGroup, KeySecurityLabelFileType)
if len(securityLabelFileType) > 0 { if ok && len(securityLabelFileType) > 0 {
podman.add("--security-opt", fmt.Sprintf("label=filetype:%s", securityLabelFileType)) podman.add("--security-opt", fmt.Sprintf("label=filetype:%s", securityLabelFileType))
} }
securityLabelLevel, _ := container.Lookup(ContainerGroup, KeySecurityLabelLevel) securityLabelLevel, ok := container.Lookup(ContainerGroup, KeySecurityLabelLevel)
if len(securityLabelLevel) > 0 { if ok && len(securityLabelLevel) > 0 {
podman.add("--security-opt", fmt.Sprintf("label=level:%s", securityLabelLevel)) podman.add("--security-opt", fmt.Sprintf("label=level:%s", securityLabelLevel))
} }

View File

@ -0,0 +1,6 @@
## assert-podman-final-args localhost/imagename
## assert-podman-args "--pids-limit" "8765432"
[Container]
Image=localhost/imagename
PidsLimit=8765432