Merge pull request #1934 from liubin/fix/1927-check-SandboxCgroupOnly-and-cgroup-v2

runtime: and cgroup and SandboxCgroupOnly check for check sub-command
This commit is contained in:
Fupan Li 2021-05-28 16:43:44 +08:00 committed by GitHub
commit a761e980e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,6 +25,7 @@ import (
"strings" "strings"
"syscall" "syscall"
"github.com/containerd/cgroups"
"github.com/kata-containers/kata-containers/src/runtime/pkg/katautils" "github.com/kata-containers/kata-containers/src/runtime/pkg/katautils"
vc "github.com/kata-containers/kata-containers/src/runtime/virtcontainers" vc "github.com/kata-containers/kata-containers/src/runtime/virtcontainers"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/oci" "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/oci"
@ -416,6 +417,11 @@ EXAMPLES:
return errors.New("check: cannot determine runtime config") 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) err := setCPUtype(runtimeConfig.HypervisorType)
if err != nil { if err != nil {
return err return err