Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interop.cgroups.FindCGroupsVersion broken for cgroups v1 #93581

Closed
janvorli opened this issue Oct 17, 2023 · 1 comment
Closed

Interop.cgroups.FindCGroupsVersion broken for cgroups v1 #93581

janvorli opened this issue Oct 17, 2023 · 1 comment
Assignees

Comments

@janvorli
Copy link
Member

While working on some cgroups related changes, I've found that the Interop.cgroups.FindCGroupsVersion was unable to detect cgroups v1. I've investigated the issue and the problem is caused by the fact that the textual result of new DriveInfo(SysFsCgroupFileSystemPath).DriveFormat returns udev instead of tmpfs. The reason is that we get the format string from the UnixFileSystemTypes enum based on the filesystem "magic" constant and the udev and tmpfs (and few others) share the same value.
The DriveInfo calls Interop.Sys.GetFormatInfoForMountPoint that converts the filesystem numeric type (the magic constant) using this:

Enum.GetName(typeof(UnixFileSystemTypes), numericFormat) ?? string.Empty :
Marshal.PtrToStringUTF8((IntPtr)formatBuffer)!;

The Interop.cgroups.FindCGroupsVersion uses this switch to detect cgroups version:

return new DriveInfo(SysFsCgroupFileSystemPath).DriveFormat switch
{
"cgroup2fs" => CGroupVersion.CGroup2,
"tmpfs" => CGroupVersion.CGroup1,
_ => CGroupVersion.None,
};

Since the name returned by the Enum.ToString is "udev", it fails to detect the cgroups 1.

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Oct 17, 2023
@janvorli janvorli self-assigned this Oct 18, 2023
@janvorli
Copy link
Member Author

Fixed by #93611

@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Oct 20, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Nov 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant