open-nomad/client/fingerprint
Seth Hoenig 2e5c6de820 client: enable support for cgroups v2
This PR introduces support for using Nomad on systems with cgroups v2 [1]
enabled as the cgroups controller mounted on /sys/fs/cgroups. Newer Linux
distros like Ubuntu 21.10 are shipping with cgroups v2 only, causing problems
for Nomad users.

Nomad mostly "just works" with cgroups v2 due to the indirection via libcontainer,
but not so for managing cpuset cgroups. Before, Nomad has been making use of
a feature in v1 where a PID could be a member of more than one cgroup. In v2
this is no longer possible, and so the logic around computing cpuset values
must be modified. When Nomad detects v2, it manages cpuset values in-process,
rather than making use of cgroup heirarchy inheritence via shared/reserved
parents.

Nomad will only activate the v2 logic when it detects cgroups2 is mounted at
/sys/fs/cgroups. This means on systems running in hybrid mode with cgroups2
mounted at /sys/fs/cgroups/unified (as is typical) Nomad will continue to
use the v1 logic, and should operate as before. Systems that do not support
cgroups v2 are also not affected.

When v2 is activated, Nomad will create a parent called nomad.slice (unless
otherwise configured in Client conifg), and create cgroups for tasks using
naming convention <allocID>-<task>.scope. These follow the naming convention
set by systemd and also used by Docker when cgroups v2 is detected.

Client nodes now export a new fingerprint attribute, unique.cgroups.version
which will be set to 'v1' or 'v2' to indicate the cgroups regime in use by
Nomad.

The new cpuset management strategy fixes #11705, where docker tasks that
spawned processes on startup would "leak". In cgroups v2, the PIDs are
started in the cgroup they will always live in, and thus the cause of
the leak is eliminated.

[1] https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v2.html

Closes #11289
Fixes #11705 #11773 #11933
2022-03-23 11:35:27 -05:00
..
test_fixtures client/fingerprint/consul: add new attributes to consul fingerprinter 2021-06-03 12:49:22 -05:00
arch.go client: Move fingerprint structs to pkg 2018-12-01 17:10:39 +01:00
arch_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
bridge.go client/fingerprint: detect unloaded dynamic bridge kernel module 2020-11-09 13:56:14 -06:00
bridge_default.go gofmt all the files 2021-10-01 10:14:28 -04:00
bridge_linux.go deps: bump gopsutil to v3.21.2 2021-03-30 16:02:51 -04:00
bridge_linux_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
cgroup.go client: enable support for cgroups v2 2022-03-23 11:35:27 -05:00
cgroup_default.go client: enable support for cgroups v2 2022-03-23 11:35:27 -05:00
cgroup_linux.go client: enable support for cgroups v2 2022-03-23 11:35:27 -05:00
cgroup_test.go client: enable support for cgroups v2 2022-03-23 11:35:27 -05:00
cni.go multi-interface network support 2020-06-19 09:42:10 -04:00
cni_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
consul.go consul: pr cleanup namespace probe function signatures 2021-06-07 15:41:01 -05:00
consul_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
cpu.go client/ar: thread through cpuset manager 2021-04-13 13:28:36 -04:00
cpu_default.go gofmt all the files 2021-10-01 10:14:28 -04:00
cpu_linux.go client: enable support for cgroups v2 2022-03-23 11:35:27 -05:00
cpu_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
env_aws.go chore: bump golangci-lint from v1.24 to v1.39 2021-04-03 09:50:23 +02:00
env_aws_cpu.go env: update aws cpu configs 2022-02-08 12:44:00 -06:00
env_aws_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
env_azure.go chore: bump golangci-lint from v1.24 to v1.39 2021-04-03 09:50:23 +02:00
env_azure_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
env_digitalocean.go fingerprint: remove metadata from digitalocean (#12032) 2022-02-09 07:31:45 -05:00
env_digitalocean_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
env_gce.go chore: bump golangci-lint from v1.24 to v1.39 2021-04-03 09:50:23 +02:00
env_gce_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
fingerprint.go add digitalocean fingerprinter 2022-02-05 22:17:36 -08:00
fingerprint_default.go gofmt all the files 2021-10-01 10:14:28 -04:00
fingerprint_linux.go CNI Implementation (#7518) 2020-06-18 11:05:29 -07:00
fingerprint_test.go fingerprint code refactor 2019-11-26 10:51:28 -05:00
host.go deps: bump gopsutil to v3.21.2 2021-03-30 16:02:51 -04:00
host_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
memory.go deps: bump gopsutil to v3.21.2 2021-03-30 16:02:51 -04:00
memory_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
network.go fix host network reserved port fingerprint (#11728) 2021-12-22 15:29:54 -05:00
network_default.go gofmt all the files 2021-10-01 10:14:28 -04:00
network_linux.go Log network device name during fingerprinting (#11184) 2021-09-16 10:48:31 -04:00
network_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
network_windows.go Disable PowerShell profile and simplify fingerprinting link speed on Windows (#11183) 2021-09-22 11:17:47 -04:00
nomad.go client: Move fingerprint structs to pkg 2018-12-01 17:10:39 +01:00
nomad_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
signal.go client: Move fingerprint structs to pkg 2018-12-01 17:10:39 +01:00
signal_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
storage.go client: Move fingerprint structs to pkg 2018-12-01 17:10:39 +01:00
storage_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
storage_unix.go gofmt all the files 2021-10-01 10:14:28 -04:00
storage_windows.go Revert "lint: ignore generated windows syscall wrappers" 2019-10-22 08:23:44 -04:00
structs.go Add gosimple linter (#9590) 2020-12-09 11:05:18 -08:00
vault.go client: Move fingerprint structs to pkg 2018-12-01 17:10:39 +01:00
vault_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
zstorage_windows.go Revert "lint: ignore generated windows syscall wrappers" 2019-10-22 08:23:44 -04:00