Skip to content

Lack of cgroups v2 Support in Microsoft.Extensions.Diagnostics.ResourceMonitoring #4885

@mobratil

Description

@mobratil

Description

I am reporting an issue with Microsoft.Extensions.Diagnostics.ResourceMonitoring related to its incompatibility with cgroups v2. This issue is particularly evident when running applications in environments that default to cgroups v2, such as Debian GNU/Linux 12 (Bookworm).

Issue Details

The library seems to be designed to work with cgroups v1, as it attempts to access /sys/fs/cgroup/memory/memory.limit_in_bytes, a path specific to the cgroups v1 hierarchy. In environments using cgroups v2, this path does not exist, leading to System.IO.DirectoryNotFoundException.

Expected Behavior

For environments using cgroups v2, the library should be able to access the appropriate cgroups v2 paths and files to monitor resources.

Actual Behavior

When running in a cgroups v2 environment, the library fails to find the required paths, resulting in an unhandled exception (DirectoryNotFoundException).

Steps to Reproduce

  1. Run an application using Microsoft.Extensions.Diagnostics.ResourceMonitoring in a Docker container on a system using cgroups v2 (e.g., Debian GNU/Linux 12).
  2. Observe the DirectoryNotFoundException when the library attempts to access cgroups v1 specific paths.

Suggested Solution

It would be beneficial for Microsoft.Extensions.Diagnostics.ResourceMonitoring to include support for cgroups v2, given its increasing adoption in newer Linux distributions.

Additional Context

This issue is crucial for applications that are intended to run in modern Linux environments where cgroups v2 is the default or only available option.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions