mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
1cd71dfd71
Some systemd properties are documented as having "Sec" suffix (e.g. "TimeoutStopSec") but are expected to have "USec" suffix when passed over dbus, so let's provide appropriate conversion to improve compatibility. This means, one can specify TimeoutStopSec with a numeric argument, in seconds, and it will be properly converted to TimeoutStopUsec with the argument in microseconds. As a side bonus, even float values are converted, so e.g. TimeoutStopSec=1.5 is possible. This turned out a bit more tricky to implement when I was originally expected, since there are a handful of numeric types in dbus and each one requires explicit conversion. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
28 lines
1.0 KiB
Markdown
28 lines
1.0 KiB
Markdown
## Changing systemd unit properties
|
|
|
|
In case runc uses systemd to set cgroup parameters for a container (i.e.
|
|
`--systemd-cgroup` CLI flag is set), systemd creates a scope (a.k.a.
|
|
transient unit) for the container, usually named like `runc-$ID.scope`.
|
|
|
|
The systemd properties of this unit (shown by `systemctl show runc-$ID.scope`
|
|
after the container is started) can be modified by adding annotations
|
|
to container's runtime spec (`config.json`). For example:
|
|
|
|
```json
|
|
"annotations": {
|
|
"org.systemd.property.TimeoutStopUSec": "uint64 123456789",
|
|
"org.systemd.property.CollectMode":"'inactive-or-failed'"
|
|
},
|
|
```
|
|
|
|
The above will set the following properties:
|
|
|
|
* `TimeoutStopSec` to 2 minutes and 3 seconds;
|
|
* `CollectMode` to "inactive-or-failed".
|
|
|
|
The values must be in the gvariant format (for details, see
|
|
[gvariant documentation](https://developer.gnome.org/glib/stable/gvariant-text.html)).
|
|
|
|
To find out which type systemd expects for a particular parameter, please
|
|
consult systemd sources.
|