Skip to content

Commit

Permalink
Warn if cgroups-v1
Browse files Browse the repository at this point in the history
Podman v5 will not support cgroups-v1. This commit will print a warning
if it detects a cgroups-v1 system.

This warning is patched out for RHEL 9 builds as cgroups-v1 will still
be supported on RHEL 9 systems.

Resolves: https://issues.redhat.com/browse/RUN-1957

[NO NEW TESTS NEEDED]

Co-authored-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com>
  • Loading branch information
lsm5 and giuseppe committed Feb 1, 2024
1 parent 4fde98f commit 3c25955
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/podman/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strconv"
"strings"

"github.com/containers/common/pkg/cgroups"
_ "github.com/containers/podman/v4/cmd/podman/completion"
_ "github.com/containers/podman/v4/cmd/podman/farm"
_ "github.com/containers/podman/v4/cmd/podman/generate"
Expand Down Expand Up @@ -40,6 +41,11 @@ func main() {
return
}

cgroupv2, _ := cgroups.IsCgroup2UnifiedMode()
if !cgroupv2 {
logrus.Warnf("WARNING! You are using cgroups-v1 which is not supported with Podman v5 and will be removed in a future version. Consider switching to cgroups-v2.")
}

if filepath.Base(os.Args[0]) == registry.PodmanSh ||
(len(os.Args[0]) > 0 && filepath.Base(os.Args[0][1:]) == registry.PodmanSh) {
shell := strings.TrimPrefix(os.Args[0], "-")
Expand Down
5 changes: 5 additions & 0 deletions rpm/podman.spec
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@ when `%{_bindir}/%{name}sh` is set as a login shell or set as os.Args[0].
%autosetup -Sgit -n %{name}-%{version_no_tilde}
sed -i 's;@@PODMAN@@\;$(BINDIR);@@PODMAN@@\;%{_bindir};' Makefile

# cgroups-v1 is supported on rhel9
%if 0%{?rhel} == 9
sed -i '/WARNING! You are using cgroups-v1/d' cmd/podman/main.go
%endif

# These changes are only meant for copr builds
%if %{defined copr_build}
# podman --version should show short sha
Expand Down

0 comments on commit 3c25955

Please sign in to comment.