Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
de26530
cmd/podman.persistentRunE(): Fatal linux check if no Cgroups v2
lsm5 Nov 3, 2025
8846d1e
cmd/podman/containers/unpause: Remove cgroupv1 check
lsm5 Nov 3, 2025
49943da
libpod/container_internal*.go: Remove Cgroups v1
lsm5 Nov 5, 2025
5d39107
libpod/info_linux.go: Remove Cgroups v1
lsm5 Nov 5, 2025
2ba50f4
libpod/runtime_linux.go: Remove Cgroups v1
lsm5 Nov 3, 2025
a1b2b86
libpod/runtime_pod_linux.go: Remove Cgroups v1
lsm5 Nov 3, 2025
afcac3b
pkg/domain/infra/runtime_libpod.go: Remove Cgroups v1
lsm5 Nov 3, 2025
30c6df7
pkg/specgen/generate/validate_linux.go: Remove Cgroups v1
lsm5 Nov 3, 2025
b6d2edb
libpod/runtime_ctr.go: Remove Cgroups v1
lsm5 Nov 5, 2025
81c3064
libpod/runtime.go: Remove Cgroups v1
lsm5 Nov 5, 2025
3a04ccc
libpod/util_linux.go: Remove Cgroups v1
lsm5 Nov 5, 2025
70dc291
libpod/pod_api.go: Remove Cgroups v1
lsm5 Nov 5, 2025
c6ecc1b
pkg/specgen/namespaces.go: Remove Cgroups v1
lsm5 Nov 5, 2025
ecf7f7f
pkg/domain/infra/abi/pods_stats.go: Remove Cgroups v1
lsm5 Nov 5, 2025
4984ec0
pkg/domain/infra/abi/containers.go: Remove Cgroups v1
lsm5 Nov 5, 2025
103dafc
pkg/api/handlers/libpod/containers_stats.go: Remove Cgroups v1
lsm5 Nov 5, 2025
8adc31c
cmd/podman/system/service_abi_linux.go: Remove Cgroups v1
lsm5 Nov 5, 2025
c10f35c
pkg/api/handlers/compat/containers_create.go: Remove Cgroups v1
lsm5 Nov 5, 2025
471feaf
test/e2e: delete CgV1 skips, delete tests skipped on Cgv2
lsm5 Nov 5, 2025
c09e4bf
test/system: delete CgV1 skips and skipped CgV2 tests
lsm5 Nov 5, 2025
51e47cf
docs: Remove Cgroups v1
lsm5 Nov 5, 2025
797b985
Remove ContainerStats.PerCPU: CGV1 only
lsm5 Nov 5, 2025
6773dca
test/system: Remove cgroupVersion from podman info tests
lsm5 Nov 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions cmd/podman/containers/unpause.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package containers

import (
"context"
"errors"
"fmt"
"os"
"strings"
Expand All @@ -12,9 +11,7 @@ import (
"github.com/containers/podman/v6/cmd/podman/utils"
"github.com/containers/podman/v6/cmd/podman/validate"
"github.com/containers/podman/v6/pkg/domain/entities"
"github.com/containers/podman/v6/pkg/rootless"
"github.com/spf13/cobra"
"go.podman.io/common/pkg/cgroups"
"go.podman.io/common/pkg/completion"
)

Expand Down Expand Up @@ -93,13 +90,6 @@ func unpause(_ *cobra.Command, args []string) error {
)
args = utils.RemoveSlash(args)

if rootless.IsRootless() && !registry.IsRemote() {
cgroupv2, _ := cgroups.IsCgroup2UnifiedMode()
if !cgroupv2 {
return errors.New("unpause is not supported for cgroupv1 rootless containers")
}
}

for _, cidFile := range unpauseCidFiles {
content, err := os.ReadFile(cidFile)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions cmd/podman/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
18 changes: 18 additions & 0 deletions cmd/podman/root_cgroups_linux.go
Original file line number Diff line number Diff line change
@@ -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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will entirely prevent running Podman (not even --version) when /sys is not available or readable. Is that OK?

(OTOH if we did not abort on an error here, we might still want to abort later if cgroups are not accessible… the c/common PR had a similar iteration. I don’t know enough to have an opinion.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mheon @Luap99 wdyt ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could move it into persistentPreRunE() which should guard all commands that would care about cgroup setup but not block --version

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}
if !unified {
logrus.Fatalf("Cgroups v1 not supported")
}
}
7 changes: 7 additions & 0 deletions cmd/podman/root_cgroups_unsupported.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//go:build !linux

package main

func checkSupportedCgroups() {
// NOP on Non Linux
}
6 changes: 0 additions & 6 deletions cmd/podman/system/service_abi_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
package system

import (
"github.com/containers/podman/v6/pkg/rootless"
"github.com/sirupsen/logrus"
"go.podman.io/common/pkg/cgroups"
"go.podman.io/common/pkg/servicereaper"
Expand All @@ -15,11 +14,6 @@ func maybeStartServiceReaper() {
}

func maybeMoveToSubCgroup() {
cgroupv2, _ := cgroups.IsCgroup2UnifiedMode()
if rootless.IsRootless() && !cgroupv2 {
logrus.Warnf("Running 'system service' in rootless mode without cgroup v2, containers won't survive a 'system service' restart")
}

if err := cgroups.MaybeMoveToSubCgroup(); err != nil {
// it is a best effort operation, so just print the
// error for debugging purposes.
Expand Down
17 changes: 1 addition & 16 deletions docs/source/locale/ja/LC_MESSAGES/markdown.po
Original file line number Diff line number Diff line change
Expand Up @@ -26352,16 +26352,9 @@ msgstr ""
msgid "Display a live stream of one or more containers' resource usage statistics"
msgstr ""

#: ../../source/markdown/podman-stats.1.md:15
msgid ""
"Note: Podman stats does not work in rootless environments that use "
"CGroups V1. Podman stats relies on CGroup information for statistics, and"
" CGroup v1 is not supported for rootless use cases."
msgstr ""

#: ../../source/markdown/podman-stats.1.md:19
msgid ""
"Note: Rootless environments that use CGroups V2 are not able to report "
"Note: Rootless environments are not able to report "
"statistics about their networking usage."
msgstr ""

Expand Down Expand Up @@ -26481,10 +26474,6 @@ msgstr ""
msgid "Network Output"
msgstr ""

#: ../../source/markdown/podman-stats.1.md:1
msgid ".PerCPU"
msgstr ""

#: ../../source/markdown/podman-stats.1.md:1
msgid "CPU time consumed by all tasks [1]"
msgstr ""
Expand Down Expand Up @@ -26521,10 +26510,6 @@ msgstr ""
msgid "Same as UpTime"
msgstr ""

#: ../../source/markdown/podman-stats.1.md:64
msgid "[1] Cgroups V1 only"
msgstr ""

#: ../../source/markdown/podman-stats.1.md:68
msgid "**--interval**, **-i**=*seconds*"
msgstr ""
Expand Down
9 changes: 1 addition & 8 deletions docs/source/markdown/podman-stats.1.md.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ podman\-stats - Display a live stream of one or more container's resource usage
## DESCRIPTION
Display a live stream of one or more containers' resource usage statistics

Note: Podman stats does not work in rootless environments that use cgroups v1.
Podman stats relies on cgroup information for statistics, and cgroup v1 is not
supported for rootless use cases.

Note: Rootless environments that use cgroups v2 are not able to report statistics
Note: Rootless environments are not able to report statistics
about their networking usage.

## OPTIONS
Expand Down Expand Up @@ -52,15 +48,12 @@ Valid placeholders for the Go template are listed below:
| .Name | Container Name |
| .NetIO | Network IO |
| .Network ... | Network I/O, separated by network interface |
| .PerCPU | CPU time consumed by all tasks [1] |
| .PIDs | Number of PIDs |
| .PIDS | Number of PIDs (yes, we know this is a dup) |
| .SystemNano | Current system datetime, nanoseconds since epoch |
| .Up | Duration (CPUNano), in human-readable form |
| .UpTime | Same as Up |

[1] Cgroups V1 only

When using a Go template, precede the format with `table` to print headers.

#### **--interval**, **-i**=*seconds*
Expand Down
1 change: 0 additions & 1 deletion docs/source/markdown/podman.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ The CDI spec directory path (may be set multiple times). Default path is `/etc/c
The CGroup manager to use for container cgroups. Supported values are __cgroupfs__ or __systemd__. Default is _systemd_ unless overridden in the containers.conf file.

Note: Setting this flag can cause certain commands to break when called on containers previously created by the other CGroup manager type.
Note: CGroup manager is not supported in rootless mode when using CGroups Version V1.

#### **--config**
Location of config file. Mainly for docker compatibility, only the authentication parts of the config are supported.
Expand Down
41 changes: 7 additions & 34 deletions libpod/container_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import (
"github.com/opencontainers/selinux/go-selinux/label"
"github.com/sirupsen/logrus"
"go.podman.io/common/libnetwork/etchosts"
"go.podman.io/common/pkg/cgroups"
"go.podman.io/common/pkg/chown"
"go.podman.io/common/pkg/config"
"go.podman.io/common/pkg/hooks"
Expand Down Expand Up @@ -1361,41 +1360,25 @@ func (c *Container) waitForHealthy(ctx context.Context) error {
}

// Whether a container should use `all` when stopping
func (c *Container) stopWithAll() (bool, error) {
func (c *Container) stopWithAll() bool {
// If the container is running in a PID Namespace, then killing the
// primary pid is enough to kill the container. If it is not running in
// a pid namespace then the OCI Runtime needs to kill ALL processes in
// the container's cgroup in order to make sure the container is stopped.
all := !c.hasNamespace(spec.PIDNamespace)
// We can't use --all if Cgroups aren't present.
// Rootless containers with Cgroups v1 and NoCgroups are both cases
// where this can happen.
if all {
if c.config.NoCgroups {
all = false
} else if rootless.IsRootless() {
// Only do this check if we need to
unified, err := cgroups.IsCgroup2UnifiedMode()
if err != nil {
return false, err
}
if !unified {
all = false
}
}
// Rootless containers with NoCgroups is a case where this can happen.
if all && c.config.NoCgroups {
all = false
}

return all, nil
return all
}

// Internal, non-locking function to stop container
func (c *Container) stop(timeout uint) error {
logrus.Debugf("Stopping ctr %s (timeout %d)", c.ID(), timeout)

all, err := c.stopWithAll()
if err != nil {
return err
}
all := c.stopWithAll()

// OK, the following code looks a bit weird but we have to make sure we can stop
// containers with the restart policy always, to do this we have to set
Expand Down Expand Up @@ -1502,7 +1485,7 @@ func (c *Container) waitForConmonToExitAndSave() error {
// could open a pidfd on container PID1 before
// this to get the real exit code... But I'm not
// that dedicated.
all, _ := c.stopWithAll()
all := c.stopWithAll()
if err := c.ociRuntime.StopContainer(c, 0, all); err != nil {
logrus.Errorf("Error stopping container %s after Conmon exited prematurely: %v", c.ID(), err)
}
Expand Down Expand Up @@ -1559,16 +1542,6 @@ func (c *Container) pause() error {
return fmt.Errorf("cannot pause without using Cgroups: %w", define.ErrNoCgroups)
}

if rootless.IsRootless() {
cgroupv2, err := cgroups.IsCgroup2UnifiedMode()
if err != nil {
return fmt.Errorf("failed to determine cgroupversion: %w", err)
}
if !cgroupv2 {
return fmt.Errorf("can not pause containers on rootless containers with cgroup V1: %w", define.ErrNoCgroups)
}
}

if c.state.HCUnitName != "" {
if err := c.removeTransientFiles(context.Background(),
c.config.StartupHealthCheckConfig != nil && !c.state.StartupHCPassed,
Expand Down
Loading