Skip to content

Conversation

@sohankunkerkar
Copy link
Member

@sohankunkerkar sohankunkerkar commented Nov 3, 2025

When using systemd cgroup driver with cgroup v2, unconditionally enable TasksAccounting. This ensures the pids controller is available even when no explicit pids resource limit is configured.

Without this, CRI-O cannot read pids.current from the cgroup, resulting in ProcessCount being reported as 0 for pod sandboxes. This causes Kubernetes Summary API conformance tests to fail.

The issue manifests specifically with pause/infra containers which typically do not have pids limits configured, leading to TasksAccounting not being enabled in the systemd scope properties.

This behavior matches what runc has been doing for a long time, where it unconditionally enables TasksAccounting for cgroup v2.

Fixes: cri-o/cri-o#9536

Summary by Sourcery

Unconditionally enable TasksAccounting in systemd cgroup v2 scopes to ensure the pids controller is available and fix ProcessCount reporting in CRI-O.

Bug Fixes:

  • Always enable TasksAccounting in systemd cgroup scopes even when no pids limit is configured

Enhancements:

  • Align libcrun behavior with runc by unconditionally enabling TasksAccounting for cgroup v2

When using systemd cgroup driver with cgroup v2, unconditionally enable
TasksAccounting. This ensures the pids controller is available even when
no explicit pids resource limit is configured.

Without this, container managers like CRI-O cannot read pids.current from
the cgroup, resulting in ProcessCount being reported as 0 for pod sandboxes.
This causes Kubernetes Summary API conformance tests to fail.

The issue manifests specifically with pause/infra containers which typically
do not have pids limits configured, leading to TasksAccounting not being
enabled in the systemd scope properties.

Fixes: cri-o/cri-o#9536
Signed-off-by: Sohan Kunkerkar <[email protected]>
@sourcery-ai
Copy link

sourcery-ai bot commented Nov 3, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

In the systemd cgroup driver code for cgroup v2, TasksAccounting is now enabled unconditionally—removing the old guard and adding an explanatory comment—so that the pids controller is always active and CRI-O can correctly report pids.current as runc does.

File-Level Changes

Change Details Files
Unconditionally enable TasksAccounting for systemd cgroup scopes
  • Remove the 'if (resources->pids)' guard around TasksAccounting
  • Add an unconditional boolean_opts entry for 'TasksAccounting'
  • Insert comment explaining why TasksAccounting must always be enabled
src/libcrun/cgroup-systemd.c

Assessment against linked issues

Issue Objective Addressed Explanation
cri-o/cri-o#9536 Ensure that ProcessCount in pod sandbox stats is correctly populated (>=1) when using crun as the OCI runtime with systemd cgroup v2, matching the behavior of runc.
cri-o/cri-o#9536 Enable TasksAccounting unconditionally for systemd cgroup v2 in crun, so that the pids controller is available and pids.current can be read even when no explicit pids resource limit is configured.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Collaborator

@flouthoc flouthoc left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

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

LGTM

@giuseppe giuseppe merged commit efe1ceb into containers:main Nov 3, 2025
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ProcessCount stats returns 0 when using crun runtime, causing Kubernetes conformance test failures

3 participants