open-nomad/command/agent
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
..
consul ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
event make auditor interface more explicit 2020-03-23 19:32:58 -04:00
host ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
monitor ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
pprof ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
test-resources Update IsEmpty to check for pre-1.2.4 fields (#11930) 2022-01-28 14:41:49 -05:00
testdata core: remove all traces of unused protocol version 2022-02-18 16:12:36 -08:00
acl_endpoint.go HTTP API support for 'nomad ui -login' 2021-03-10 08:17:56 -05:00
acl_endpoint_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
agent.go core: switch to go.etc.io/bbolt 2022-02-23 14:26:41 -06:00
agent_endpoint.go api: prevent excessice CPU load on job parse 2022-02-09 19:51:47 -05:00
agent_endpoint_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
agent_oss.go gofmt all the files 2021-10-01 10:14:28 -04:00
agent_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
alloc_endpoint.go provide -no-shutdown-delay flag for job/alloc stop (#11596) 2021-12-13 14:54:53 -05:00
alloc_endpoint_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
bindata_assetfs.go Generate files for 1.2.4 release 2022-01-18 23:43:00 +00:00
command.go core: remove all traces of unused protocol version 2022-02-18 16:12:36 -08:00
command_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
config.go client: enable support for cgroups v2 2022-03-23 11:35:27 -05:00
config_oss.go gofmt all the files 2021-10-01 10:14:28 -04:00
config_parse.go Expose Consul template configuration parameters (#11606) 2022-01-10 10:19:07 -05:00
config_parse_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
config_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
csi_endpoint.go CSI: presentation improvements (#12325) 2022-03-22 09:48:38 -04:00
csi_endpoint_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
deployment_endpoint.go initial base work for implementing sorting and filter across API endpoints (#12076) 2022-02-16 14:34:36 -05:00
deployment_endpoint_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
eval_endpoint.go api: add related evals to eval details (#12305) 2022-03-17 13:56:14 -04:00
eval_endpoint_test.go api: add related evals to eval details (#12305) 2022-03-17 13:56:14 -04:00
event_endpoint.go return 405 on non-GET requests to /v1/event/stream (fixes #9526) (#9564) 2020-12-08 13:09:20 -05:00
event_endpoint_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
fs_endpoint.go api: return 404 for alloc FS list/stat endpoints (#11482) 2021-11-17 11:15:07 -05:00
fs_endpoint_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
helpers.go client: expose task state to client 2018-10-16 16:56:55 -07:00
helpers_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
http.go Add pagination, filtering and sort to more API endpoints (#12186) 2022-03-08 20:54:17 -05:00
http_oss.go gofmt all the files 2021-10-01 10:14:28 -04:00
http_stdlog.go agent: route http logs through hclog 2020-04-20 10:33:40 -04:00
http_stdlog_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
http_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
job_endpoint.go api: prevent excessice CPU load on job parse 2022-02-09 19:51:47 -05:00
job_endpoint_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
keyring.go Log AES-128 and AES-192 key sizes during keyring initialization 2020-10-01 11:12:14 -04:00
keyring_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
log_file.go prevent active log from being overwritten when agent starts (#11386) 2021-10-26 20:57:07 -04:00
log_file_bsd.go freebsd: build fix for ARM7 32-bit (#11854) 2022-01-14 12:25:32 -05:00
log_file_linux.go prevent active log from being overwritten when agent starts (#11386) 2021-10-26 20:57:07 -04:00
log_file_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
log_file_windows.go prevent active log from being overwritten when agent starts (#11386) 2021-10-26 20:57:07 -04:00
log_levels.go Support for hot reloading log levels 2019-07-24 13:37:08 +02:00
log_levels_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
metrics_endpoint.go agent: return req error if prometheus metrics are disabled. 2021-03-09 15:28:58 +01:00
metrics_endpoint_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
namespace_endpoint.go core: open source namespaces 2020-10-22 15:26:32 -07:00
namespace_endpoint_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
node_endpoint.go Node Drain Metadata (#10250) 2021-05-07 13:58:40 -04:00
node_endpoint_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
operator_endpoint.go scheduler: config option to reject job registration (#11610) 2021-12-06 15:20:34 -05:00
operator_endpoint_oss.go gofmt all the files 2021-10-01 10:14:28 -04:00
operator_endpoint_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
plugins.go move pluginutils -> helper/pluginutils 2019-01-22 15:50:08 -08:00
region_endpoint.go
region_endpoint_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
retry_join.go agent + consul 2018-09-13 10:43:40 -07:00
retry_join_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
scaling_endpoint.go Add gocritic to golangci-lint config (#9556) 2020-12-08 12:47:04 -08:00
scaling_endpoint_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
search_endpoint.go api: implement fuzzy search API 2021-04-16 16:36:07 -06:00
search_endpoint_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
stats_endpoint.go Server side impl + touch ups 2018-02-15 13:59:02 -08:00
stats_endpoint_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
status_endpoint.go
status_endpoint_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
stub_asset.go gofmt all the files 2021-10-01 10:14:28 -04:00
syslog.go goimports 2019-01-22 15:44:31 -08:00
syslog_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
system_endpoint.go
system_endpoint_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
testagent.go ci: limit gotestsum to circle ci 2022-03-18 09:15:01 -05:00
testagent_oss.go gofmt all the files 2021-10-01 10:14:28 -04:00
testingutils_test.go mock: add default host network 2020-11-23 10:11:00 -06:00