runc/libcontainer/configs
Kir Kolyshkin 4c5c3fb960 Support for setting systemd properties via annotations
In case systemd is used to set cgroups for the container,
it creates a scope unit dedicated to it (usually named
`runc-$ID.scope`).

This patch adds an ability to set arbitrary systemd properties
for the systemd unit via runtime spec annotations.

Initially this was developed as an ability to specify the
`TimeoutStopUSec` property, but later generalized to work with
arbitrary ones.

Example usage: add the following to runtime spec (config.json):

```
	"annotations": {
		"org.systemd.property.TimeoutStopUSec": "uint64 123456789",
		"org.systemd.property.CollectMode":"'inactive-or-failed'"
	},
```

and start the container (e.g. `runc --systemd-cgroup run $ID`).

The above will set the following systemd parameters:
* `TimeoutStopSec` to 2 minutes and 3 seconds,
* `CollectMode` to "inactive-or-failed".

The values are in the gvariant format (see [1]). To figure out
which type systemd expects for a particular parameter, see
systemd sources.

In particular, parameters with `USec` suffix require an `uint64`
typed argument, while gvariant assumes int32 for a numeric values,
therefore the explicit type is required.

NOTE that systemd receives the time-typed parameters as *USec
but shows them (in `systemctl show`) as *Sec. For example,
the stop timeout should be set as `TimeoutStopUSec` but
is shown as `TimeoutStopSec`.

[1] https://developer.gnome.org/glib/stable/gvariant-text.html

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-02-17 16:07:19 -08:00
..
validate Add support for cgroup namespace 2018-10-31 10:51:43 -04:00
blkio_device.go libcontainer: add initial support for cgroups v2 2019-09-05 13:02:25 +02:00
cgroup_linux.go Support for setting systemd properties via annotations 2020-02-17 16:07:19 -08:00
cgroup_unsupported.go Rename cgroups_windows.go to cgroups_unsupported.go 2019-08-26 18:13:52 -04:00
config.go Add SCMP_ACT_LOG as a valid Seccomp action (#1951) 2019-09-26 11:03:03 -04:00
config_linux.go Clean up unix vs linux usage 2017-05-12 17:22:09 +01:00
config_linux_test.go Clean up unix vs linux usage 2017-05-12 17:22:09 +01:00
config_test.go libcontainer: Set 'status' in hook stdin 2018-11-14 06:49:49 -08:00
config_windows_test.go Windows: Refactor state struct 2015-10-26 14:45:20 -07:00
device.go Update runc for devices changes 2016-02-08 13:15:12 -08:00
device_defaults.go libcontainer: drop FreeBSD support 2017-11-24 14:51:05 +01:00
hugepage_limit.go Adjust runc to new opencontainers/specs version 2015-10-03 12:25:33 +02:00
intelrdt.go libcontainer: intelrdt: add support for Intel RDT/MBA Software Controller in runc 2018-11-13 23:27:08 +08:00
interface_priority_map.go Move libcontainer into subdirectory 2015-06-21 19:29:15 -07:00
mount.go config: Add new Extensions flag to support custom mount options in runc 2016-09-30 09:46:46 -07:00
namespaces.go Move libcontainer into subdirectory 2015-06-21 19:29:15 -07:00
namespaces_linux.go libcontainer: implement CLONE_NEWCGROUP 2018-10-23 16:23:00 -04:00
namespaces_syscall.go Add support for cgroup namespace 2018-10-31 10:51:43 -04:00
namespaces_syscall_unsupported.go Fix go_vet errors 2017-01-06 10:20:27 +08:00
namespaces_unsupported.go Clean up unix vs linux usage 2017-05-12 17:22:09 +01:00
network.go Move libcontainer into subdirectory 2015-06-21 19:29:15 -07:00