libct/cg: simplify getting cgroup manager

1. Make Rootless and Systemd flags part of config.Cgroups.

2. Make all cgroup managers (not just fs2) return error (so it can do
   more initialization -- added by the following commits).

3. Replace complicated cgroup manager instantiation in factory_linux
   by a single (and simple) libcontainer/cgroups/manager.New() function.

4. getUnifiedPath is simplified to check that only a single path is
   supplied (rather than checking that other paths, if supplied,
   are the same).

[v2: can't -> cannot]

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2021-08-07 12:22:16 -07:00
parent 147ad561e8
commit 097c6d7425
17 changed files with 188 additions and 222 deletions
+1 -7
View File
@@ -126,16 +126,10 @@ func newContainer(t *testing.T, config *configs.Config) (libcontainer.Container,
name := strings.ReplaceAll(t.Name(), "/", "_") + strconv.FormatInt(-int64(time.Now().Nanosecond()), 35)
root := t.TempDir()
f, err := libcontainer.New(root, libcontainer.Cgroupfs)
f, err := libcontainer.New(root)
if err != nil {
return nil, err
}
if config.Cgroups != nil && config.Cgroups.Parent == "system.slice" {
f, err = libcontainer.New(root, libcontainer.SystemdCgroups)
if err != nil {
return nil, err
}
}
return f.Create(name, config)
}