mirror of
https://github.com/containers/podman.git
synced 2025-11-29 09:37:38 +08:00
cmd/podman.persistentRunE(): Fatal linux check if no Cgroups v2
Will log and proceed on non-linux env. Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com>
This commit is contained in:
@@ -248,6 +248,8 @@ func setupRemoteConnection(podmanConfig *entities.PodmanConfig) string {
|
|||||||
func persistentPreRunE(cmd *cobra.Command, args []string) error {
|
func persistentPreRunE(cmd *cobra.Command, args []string) error {
|
||||||
logrus.Debugf("Called %s.PersistentPreRunE(%s)", cmd.Name(), strings.Join(os.Args, " "))
|
logrus.Debugf("Called %s.PersistentPreRunE(%s)", cmd.Name(), strings.Join(os.Args, " "))
|
||||||
|
|
||||||
|
checkSupportedCgroups()
|
||||||
|
|
||||||
// Help, completion and commands with subcommands are special cases, no need for more setup
|
// Help, completion and commands with subcommands are special cases, no need for more setup
|
||||||
// Completion cmd is used to generate the shell scripts
|
// Completion cmd is used to generate the shell scripts
|
||||||
if cmd.Name() == "help" || cmd.Name() == "completion" || cmd.HasSubCommands() {
|
if cmd.Name() == "help" || cmd.Name() == "completion" || cmd.HasSubCommands() {
|
||||||
|
|||||||
18
cmd/podman/root_cgroups_linux.go
Normal file
18
cmd/podman/root_cgroups_linux.go
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
//go:build linux
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
"go.podman.io/common/pkg/cgroups"
|
||||||
|
)
|
||||||
|
|
||||||
|
func checkSupportedCgroups() {
|
||||||
|
unified, err := cgroups.IsCgroup2UnifiedMode()
|
||||||
|
if err != nil {
|
||||||
|
logrus.Fatalf("Error determining cgroups mode")
|
||||||
|
}
|
||||||
|
if !unified {
|
||||||
|
logrus.Fatalf("Cgroups v1 not supported")
|
||||||
|
}
|
||||||
|
}
|
||||||
7
cmd/podman/root_cgroups_unsupported.go
Normal file
7
cmd/podman/root_cgroups_unsupported.go
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
//go:build !linux
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
func checkSupportedCgroups() {
|
||||||
|
// NOP on Non Linux
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user