Fix: skip cgroup filesystem type check when cgroups are disabled#2062
Merged
giuseppe merged 1 commit intocontainers:mainfrom Apr 1, 2026
Merged
Fix: skip cgroup filesystem type check when cgroups are disabled#2062giuseppe merged 1 commit intocontainers:mainfrom
giuseppe merged 1 commit intocontainers:mainfrom
Conversation
When --cgroup-manager=disabled (force_no_cgroup) is set, crun should not attempt to detect the cgroup mode by calling statfs on /sys/fs/cgroup. On systems where /sys/fs/cgroup is not mounted as tmpfs or cgroup2 (e.g. Android with Linux Deploy where it is mounted as sysfs), this causes a spurious 'invalid file system type' error even though cgroups are explicitly disabled. Guard the libcrun_get_cgroup_mode() calls in libcrun_container_run_internal() and libcrun_set_mounts() with a check for force_no_cgroup, so the cgroup filesystem type verification and the cgroup v1 deprecation warning are both skipped when cgroups are disabled. Closes: containers#1413 Signed-off-by: Jindrich Novy <jnovy@redhat.com>
|
Warning Gemini is experiencing higher than usual traffic and was unable to create the review. Please try again in a few hours by commenting |
giuseppe
approved these changes
Apr 1, 2026
Member
giuseppe
left a comment
There was a problem hiding this comment.
is this enough to work on a system without /sys/fs/cgroup?
If so, LGTM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1413
Problem
When
--cgroup-manager=disabledis used (or--cgroups=disabledvia podman), crun still unconditionally callslibcrun_get_cgroup_mode()early in the container startup path. This function doesstatfs("/sys/fs/cgroup")and returns an error if the filesystem type is neitherCGROUP2_SUPER_MAGICnorTMPFS_MAGIC.On systems where
/sys/fs/cgroupis not a standard cgroup mount — such as Android with Linux Deploy where it is mounted assysfs— this causes container creation to fail with:This defeats the purpose of
--cgroups=disabled, which exists precisely for environments where cgroups are not properly available.Root Cause
In
libcrun_container_run_internal()(container.c),libcrun_get_cgroup_mode()is called beforesetup_cgroup_manager(), which is wherecontext->force_no_cgroupis evaluated. The same pattern exists inlibcrun_set_mounts()(linux.c), where the cgroup mode is queried unconditionally to determine the unified cgroup path.Fix
Guard the
libcrun_get_cgroup_mode()calls and related cgroup logic with checks forcontext->force_no_cgroup:src/libcrun/container.c: Skip the cgroup mode detection and the cgroup v1 deprecation warning whenforce_no_cgroupis set.src/libcrun/linux.c: Skip the cgroup mode detection and unified cgroup path reading inlibcrun_set_mounts()whenforce_no_cgroupis set.Testing
Added two regression tests in
tests/test_cgroup_setup.py:test_cgroup_disabled()— verifies that a foreground container with--cgroup-manager=disabledruns successfully without triggering cgroup filesystem validation.test_cgroup_disabled_detach()— verifies the same for the create+start (detached) code path.All existing tests continue to pass.
Reproduction
Signed-off-by: Jindrich Novy jnovy@redhat.com