From e48c9d426d53fab76f35e24d7454662cd470b3fc Mon Sep 17 00:00:00 2001 From: bin Date: Thu, 27 May 2021 16:42:50 +0800 Subject: [PATCH] runtime: and cgroup and SandboxCgroupOnly check for check sub-command In kata-runtime check sub-command, checks cgroups and SandboxCgroupOnly to show message if the SandboxCgroupOnly is not set to true and cgroup v2 is used. Fixes: #1927 Signed-off-by: bin --- src/runtime/cli/kata-check.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/runtime/cli/kata-check.go b/src/runtime/cli/kata-check.go index 66f6b2becb..2e3cb24103 100644 --- a/src/runtime/cli/kata-check.go +++ b/src/runtime/cli/kata-check.go @@ -25,6 +25,7 @@ import ( "strings" "syscall" + "github.com/containerd/cgroups" "github.com/kata-containers/kata-containers/src/runtime/pkg/katautils" vc "github.com/kata-containers/kata-containers/src/runtime/virtcontainers" "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/oci" @@ -416,6 +417,11 @@ EXAMPLES: return errors.New("check: cannot determine runtime config") } + // check if cgroup can work use the same logic for creating containers + if _, err := vc.V1Constraints(); err != nil && err == cgroups.ErrMountPointNotExist && !runtimeConfig.SandboxCgroupOnly { + return fmt.Errorf("Cgroup v2 requires the following configuration: `sandbox_cgroup_only=true`.") + } + err := setCPUtype(runtimeConfig.HypervisorType) if err != nil { return err