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: Ed Santiago <santiago@redhat.com>
Co-authored-by: Sascha Grunert <sgrunert@redhat.com>
Co-authored-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com>
  • Loading branch information
4 people committed Feb 5, 2024
1 parent daf7a2c commit 15a49b2
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ build_task:
VM_IMAGE_NAME: ${DEBIAN_CACHE_IMAGE_NAME}
CI_DESIRED_RUNTIME: runc
CI_DESIRED_NETWORK: netavark
# Ignore cgroups-v1 warnings on debian
IGNORE_CGROUPSV1_WARNING: true
env:
TEST_FLAVOR: build
# NOTE: The default way Cirrus-CI clones is *NOT* compatible with
Expand Down
2 changes: 1 addition & 1 deletion contrib/cirrus/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ EPOCH_TEST_COMMIT="$CIRRUS_BASE_SHA"
# contexts, such as host->container or root->rootless user
#
# List of envariables which must be EXACT matches
PASSTHROUGH_ENV_EXACT='CGROUP_MANAGER|DEST_BRANCH|DISTRO_NV|GOCACHE|GOPATH|GOSRC|NETWORK_BACKEND|OCI_RUNTIME|ROOTLESS_USER|SCRIPT_BASE|SKIP_USERNS|EC2_INST_TYPE|PODMAN_DB|STORAGE_FS'
PASSTHROUGH_ENV_EXACT='CGROUP_MANAGER|DEST_BRANCH|DISTRO_NV|GOCACHE|GOPATH|GOSRC|IGNORE_CGROUPSV1_WARNING|NETWORK_BACKEND|OCI_RUNTIME|ROOTLESS_USER|SCRIPT_BASE|SKIP_USERNS|EC2_INST_TYPE|PODMAN_DB|STORAGE_FS'

# List of envariable patterns which must match AT THE BEGINNING of the name.
PASSTHROUGH_ENV_ATSTART='CI|LANG|LC_|TEST'
Expand Down
9 changes: 9 additions & 0 deletions libpod/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,15 @@ func makeRuntime(runtime *Runtime) (retErr error) {
runtime.mergeDBConfig(dbConfig)

unified, _ := cgroups.IsCgroup2UnifiedMode()
// DELETE ON RHEL9
if !unified {
_, ok := os.LookupEnv("IGNORE_CGROUPSV1_WARNING")
if !ok {
logrus.Warn("Using cgroups-v1 which is deprecated in favor of cgroups-v2 with Podman v5 and will be removed in a future version. Set environment variable `IGNORE_CGROUPSV1_WARNING` to hide this warning.")
}
}
// DELETE ON RHEL9

if unified && rootless.IsRootless() && !systemd.IsSystemdSessionValid(rootless.GetRootlessUID()) {
// If user is rootless and XDG_RUNTIME_DIR is found, podman will not proceed with /tmp directory
// it will try to use existing XDG_RUNTIME_DIR
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 '/DELETE ON RHEL9/,/DELETE ON RHEL9/d' libpod/runtime.go
%endif

# These changes are only meant for copr builds
%if %{defined copr_build}
# podman --version should show short sha
Expand Down
5 changes: 5 additions & 0 deletions test/system/120-load.bats
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ verify_iid_and_name() {
skip "impossible due to pitfalls in our SSH implementation"
fi

# See https://github.com/containers/podman/pull/21431
if [[ -n "$IGNORE_CGROUPSV1_WARNING" ]]; then
skip "impossible to test due to pitfalls in our SSH implementation"
fi

# The testing is the same whether we're root or rootless; all that
# differs is the destination (not-me) username.
if is_rootless; then
Expand Down
5 changes: 5 additions & 0 deletions test/system/252-quadlet.bats
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ Notify=yes
LogDriver=passthrough
EOF

# FIXME: Temporary until podman fully removes cgroupsv1 support; see #21431
if [[ -n "$IGNORE_CGROUPSV1_WARNING" ]]; then
echo "Environment=IGNORE_CGROUPSV1_WARNING=1" >>$quadlet_file
fi

run_quadlet "$quadlet_file"
service_setup $QUADLET_SERVICE_NAME

Expand Down

0 comments on commit 15a49b2

Please sign in to comment.