Skip to content

Commit

Permalink
Merge pull request #19955 from rhatdan/quadlet
Browse files Browse the repository at this point in the history
Add support for PidsLimit in quadlet
  • Loading branch information
openshift-merge-robot authored Sep 14, 2023
2 parents dde06ae + 4ed3273 commit 88b415e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
6 changes: 6 additions & 0 deletions docs/source/markdown/podman-systemd.unit.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ Valid options for `[Container]` are listed below:
| NoNewPrivileges=true | --security-opt no-new-privileges |
| Rootfs=/var/lib/rootfs | --rootfs /var/lib/rootfs |
| Notify=true | --sdnotify container |
| PidsLimit=10000 | --pids-limit 10000 |
| PodmanArgs=--add-host foobar | --add-host foobar |
| PublishPort=50-59 | --publish 50-59 |
| Pull=never | --pull=never |
Expand Down Expand Up @@ -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
of startup on its own.

### `PidsLimit=`

Tune the container's pids limit.
This is equivalent to the Podman `--pids-limit` option.

### `PodmanArgs=`

This key contains a list of arguments passed directly to the end of the `podman run` command
Expand Down
19 changes: 13 additions & 6 deletions pkg/systemd/quadlet/quadlet.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ const (
KeyNoNewPrivileges = "NoNewPrivileges"
KeyNotify = "Notify"
KeyOptions = "Options"
KeyPidsLimit = "PidsLimit"
KeyPodmanArgs = "PodmanArgs"
KeyPublishPort = "PublishPort"
KeyPull = "Pull"
Expand Down Expand Up @@ -169,6 +170,7 @@ var (
KeyNetwork: true,
KeyNoNewPrivileges: true,
KeyNotify: true,
KeyPidsLimit: true,
KeyPodmanArgs: true,
KeyPublishPort: true,
KeyPull: true,
Expand Down Expand Up @@ -456,18 +458,23 @@ func ConvertContainer(container *parser.UnitFile, names map[string]string, isUse
podman.add("--security-opt", "label:nested")
}

securityLabelType, _ := container.Lookup(ContainerGroup, KeySecurityLabelType)
if len(securityLabelType) > 0 {
pidsLimit, ok := container.Lookup(ContainerGroup, KeyPidsLimit)
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))
}

securityLabelFileType, _ := container.Lookup(ContainerGroup, KeySecurityLabelFileType)
if len(securityLabelFileType) > 0 {
securityLabelFileType, ok := container.Lookup(ContainerGroup, KeySecurityLabelFileType)
if ok && len(securityLabelFileType) > 0 {
podman.add("--security-opt", fmt.Sprintf("label=filetype:%s", securityLabelFileType))
}

securityLabelLevel, _ := container.Lookup(ContainerGroup, KeySecurityLabelLevel)
if len(securityLabelLevel) > 0 {
securityLabelLevel, ok := container.Lookup(ContainerGroup, KeySecurityLabelLevel)
if ok && len(securityLabelLevel) > 0 {
podman.add("--security-opt", fmt.Sprintf("label=level:%s", securityLabelLevel))
}

Expand Down
6 changes: 6 additions & 0 deletions test/e2e/quadlet/pids-limit.container
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## assert-podman-final-args localhost/imagename
## assert-podman-args "--pids-limit" "8765432"

[Container]
Image=localhost/imagename
PidsLimit=8765432

0 comments on commit 88b415e

Please sign in to comment.