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:
Lokesh Mandvekar
2025-11-03 14:01:55 -05:00
parent fffb1b3ba8
commit e860773c0d
3 changed files with 27 additions and 0 deletions

View File

@@ -248,6 +248,8 @@ func setupRemoteConnection(podmanConfig *entities.PodmanConfig) string {
func persistentPreRunE(cmd *cobra.Command, args []string) error {
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
// Completion cmd is used to generate the shell scripts
if cmd.Name() == "help" || cmd.Name() == "completion" || cmd.HasSubCommands() {

View 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")
}
}

View File

@@ -0,0 +1,7 @@
//go:build !linux
package main
func checkSupportedCgroups() {
// NOP on Non Linux
}