Skip to content

Commit 3e85b2e

Browse files
Merge pull request #27250 from nimdrak/27120
Pod Quadlet can configure podman pod stop --time
2 parents 8d71de5 + e3c9fa6 commit 3e85b2e

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

docs/source/markdown/podman-systemd.unit.5.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ a `$name.pod` file creates a `$name-pod.service` unit and a `systemd-$name` Podm
10211021

10221022
Valid options for `[Pod]` are listed below:
10231023

1024-
| **[Pod] options** | **podman pod create equivalent** |
1024+
| **[Pod] options** | **podman pod create equivalent** |
10251025
|-------------------------------------|----------------------------------------|
10261026
| AddHost=example\.com:192.168.10.11 | --add-host example.com:192.168.10.11 |
10271027
| ContainersConfModule=/etc/nvd\.conf | --module=/etc/nvd\.conf |
@@ -1042,6 +1042,7 @@ Valid options for `[Pod]` are listed below:
10421042
| PublishPort=8080:80 | --publish 8080:80 |
10431043
| ServiceName=name | Name the systemd unit `name.service` |
10441044
| ShmSize=100m | --shm-size=100m |
1045+
| StopTimeout=20 | --time=20 |
10451046
| SubGIDMap=gtest | --subgidname=gtest |
10461047
| SubUIDMap=utest | --subuidname=utest |
10471048
| UIDMap=0:10000:10 | --uidmap=0:10000:10 |
@@ -1210,6 +1211,12 @@ Size of /dev/shm.
12101211

12111212
This is equivalent to the Podman `--shm-size` option and generally has the form `number[unit]`
12121213

1214+
### `StopTimeout=`
1215+
1216+
Sets the time in seconds to wait for the pod to gracefully stop.
1217+
This value is equivalent to the `--time` argument in the podman `pod stop` command when the service is stopped.
1218+
After this period expires, any running containers in the pod are forcibly killed.
1219+
12131220
### `SubGIDMap=`
12141221

12151222
Create the pod in a new user namespace using the map with name in the /etc/subgid file.

pkg/systemd/quadlet/quadlet.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ var (
485485
KeyRemapUsers: true,
486486
KeyServiceName: true,
487487
KeyShmSize: true,
488+
KeyStopTimeout: true,
488489
KeySubGIDMap: true,
489490
KeySubUIDMap: true,
490491
KeyUIDMap: true,
@@ -1552,9 +1553,13 @@ func ConvertPod(podUnit *parser.UnitFile, unitsInfoMap map[string]*UnitInfo, isU
15521553

15531554
execStop := createBasePodmanCommand(podUnit, PodGroup)
15541555
execStop.add("pod", "stop")
1556+
stopTimeout := "10"
1557+
if value, ok := podUnit.Lookup(PodGroup, KeyStopTimeout); ok {
1558+
stopTimeout = value
1559+
}
15551560
execStop.add(
15561561
"--ignore",
1557-
"--time=10",
1562+
fmt.Sprintf("--time=%s", stopTimeout),
15581563
podName,
15591564
)
15601565
service.AddCmdline(ServiceGroup, "ExecStop", execStop.Args)

test/e2e/quadlet/stoptimeout.pod

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## assert-podman-stop-args --time=20
2+
3+
[Unit]
4+
Description=A pod with a custom stop timeout
5+
6+
[Pod]
7+
PodName=test-pod
8+
StopTimeout=20

test/e2e/quadlet_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,6 +1093,7 @@ BOGUS=foo
10931093
Entry("Pod - Remap keep-id", "remap-keep-id.pod"),
10941094
Entry("Pod - Remap manual", "remap-manual.pod"),
10951095
Entry("Pod - Shm Size", "shmsize.pod"),
1096+
Entry("Pod - StopTimeout", "stoptimeout.pod"),
10961097
Entry("Pod - Service Environment", "service-environment.pod"),
10971098
)
10981099

0 commit comments

Comments
 (0)