mirror of
https://github.com/containers/podman.git
synced 2025-11-28 00:59:30 +08:00
pkg/specgen/namespaces.go: Remove Cgroups v1
Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com>
This commit is contained in:
@@ -14,7 +14,6 @@ import (
|
|||||||
spec "github.com/opencontainers/runtime-spec/specs-go"
|
spec "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"github.com/opencontainers/runtime-tools/generate"
|
"github.com/opencontainers/runtime-tools/generate"
|
||||||
"go.podman.io/common/libnetwork/types"
|
"go.podman.io/common/libnetwork/types"
|
||||||
"go.podman.io/common/pkg/cgroups"
|
|
||||||
"go.podman.io/common/pkg/config"
|
"go.podman.io/common/pkg/config"
|
||||||
"go.podman.io/storage/pkg/fileutils"
|
"go.podman.io/storage/pkg/fileutils"
|
||||||
"go.podman.io/storage/pkg/unshare"
|
"go.podman.io/storage/pkg/unshare"
|
||||||
@@ -262,26 +261,14 @@ func ParseNamespace(ns string) (Namespace, error) {
|
|||||||
// ParseCgroupNamespace parses a cgroup namespace specification in string
|
// ParseCgroupNamespace parses a cgroup namespace specification in string
|
||||||
// form.
|
// form.
|
||||||
func ParseCgroupNamespace(ns string) (Namespace, error) {
|
func ParseCgroupNamespace(ns string) (Namespace, error) {
|
||||||
toReturn := Namespace{}
|
switch ns {
|
||||||
// Cgroup is host for v1, private for v2.
|
case "host":
|
||||||
// We can't trust c/common for this, as it only assumes private.
|
return Namespace{NSMode: Host}, nil
|
||||||
cgroupsv2, err := cgroups.IsCgroup2UnifiedMode()
|
case "private", "":
|
||||||
if err != nil {
|
return Namespace{NSMode: Private}, nil
|
||||||
return toReturn, err
|
default:
|
||||||
|
return Namespace{}, fmt.Errorf("unrecognized cgroup namespace mode %s passed", ns)
|
||||||
}
|
}
|
||||||
if cgroupsv2 {
|
|
||||||
switch ns {
|
|
||||||
case "host":
|
|
||||||
toReturn.NSMode = Host
|
|
||||||
case "private", "":
|
|
||||||
toReturn.NSMode = Private
|
|
||||||
default:
|
|
||||||
return toReturn, fmt.Errorf("unrecognized cgroup namespace mode %s passed", ns)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
toReturn.NSMode = Host
|
|
||||||
}
|
|
||||||
return toReturn, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParseIPCNamespace parses an ipc namespace specification in string
|
// ParseIPCNamespace parses an ipc namespace specification in string
|
||||||
|
|||||||
Reference in New Issue
Block a user