Repository navigation
refactor(libcgroups): Extract systemd CgroupsPath into its own module - #3935
Merged
Merged
Conversation
Replace Path::len() (via NixPath) with as_os_str().is_empty() for the empty-path check. Signed-off-by: Takuto Nagami <logica0419@gmail.com>
Signed-off-by: Takuto Nagami <logica0419@gmail.com>
Move the CgroupsPath parsing type out of systemd::manager into its own module so it can be reused without pulling in the D-Bus manager. No behavior change; register the module in systemd/mod.rs and the no-systemd stub. Signed-off-by: Takuto Nagami <logica0419@gmail.com>
Replace the in-place name mutation in Manager::new with CgroupsPath::sub_cgroup()/unit_name() backed by a free split_sub_cgroup() function, and simplify construct_cgroups_path() to read from CgroupsPath instead of taking a separate sub_cgroup argument. Move the corresponding tests to cgroups_path. Signed-off-by: Takuto Nagami <logica0419@gmail.com>
5 of 13 tasks
Member
|
@logica0419 The Basic Checks workflow is currently failing due to formatting issues in cgroups_path.rs. Could you run |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The refactor breaks the public libcgroups::systemd::manager::CgroupsPathError import path, which must be preserved with a public re-export for downstream compatibility.
1 open issue
What changed in this PR
Extracts systemd cgroup-path handling into a reusable module independent of the D-Bus manager, preparing for tenant sub-cgroup support in #3564.
Changes:
- Moves parsing and unit/sub-cgroup accessors into
CgroupsPath. - Updates the manager to use side-effect-free accessors and exposes the parser when systemd support is disabled.
- Adds parser tests and adapts existing path-construction tests.
| File | Description |
|---|---|
crates/libcgroups/src/systemd/mod.rs |
Exposes the new cgroup-path module. |
crates/libcgroups/src/systemd/manager.rs |
Uses the extracted accessors instead of mutating the parsed name. |
crates/libcgroups/src/systemd/cgroups_path.rs |
Defines the reusable parser, error type, accessors, and unit tests. |
crates/libcgroups/src/stub/systemd/mod.rs |
Exposes the same parser without the systemd feature. |
Review effort: Balanced
Signed-off-by: Takuto Nagami <logica0419@gmail.com>
Contributor
Author
|
@saku3 |
Signed-off-by: Takuto Nagami <logica0419@gmail.com>
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.

Description
Moved
CgroupsPathout ofsystemd::managerintosystemd::cgroups_pathso it can be reused without the D-Bus manager.Also replaced the in-place
namemutation with side-effect-free accessors.Stacked lower PR for #3564.
Type of Change
Testing
Related Issues
Refs #3564
Additional Context
#3564 depends on this PR.