Skip to content

Support manage-cgroup-mode option for checkpoint#3452

Merged
saku3 merged 1 commit intoyouki-dev:mainfrom
donkomura:feat-checkpoint-management-cgroups-mode
Apr 1, 2026
Merged

Support manage-cgroup-mode option for checkpoint#3452
saku3 merged 1 commit intoyouki-dev:mainfrom
donkomura:feat-checkpoint-management-cgroups-mode

Conversation

@donkomura
Copy link
Copy Markdown
Contributor

Description

Add support for CRIU's --manage-cgroup-mode option in checkpoint command. This primarily affects restore behavior, and with "ignore" mode, cgroup information will not be dumped.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test updates
  • CI/CD related changes
  • Other (please describe):

Testing

  • Added new unit tests
  • Added new integration tests
  • Ran existing test suite
  • Tested manually (please provide steps)

Related Issues

#3394

Additional Context

For detail about the option, see https://criu.org/CGroups.

Copy link
Copy Markdown
Member

@utam0k utam0k left a comment

Choose a reason for hiding this comment

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

Is it hard to add the unit or e2e test?

@donkomura
Copy link
Copy Markdown
Contributor Author

donkomura commented Mar 14, 2026

I missed that checkpoint tests were implemented in the contest. I have added test cases.

Copy link
Copy Markdown
Contributor

@nayuta723 nayuta723 left a comment

Choose a reason for hiding this comment

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

Thanks! I've left some comments. Please take a look when you have a chance.

@@ -50,8 +50,8 @@ pub struct Checkpoint {
/// #[clap(long)]
/// pub pre_dump: bool,
/// TODO: Cgroups mode
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please delete TODO comment.

Copy link
Copy Markdown
Contributor

@nayuta723 nayuta723 Mar 17, 2026

Choose a reason for hiding this comment

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

I would like to put this on hold until #3455 is merged.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is the purpose to prevent conflicts? If so, I will leave it as is.

@donkomura donkomura force-pushed the feat-checkpoint-management-cgroups-mode branch from 975e4d6 to d59fa08 Compare March 16, 2026 14:37
@donkomura donkomura requested a review from nayuta723 March 16, 2026 14:50
Copy link
Copy Markdown
Contributor

@nayuta723 nayuta723 left a comment

Choose a reason for hiding this comment

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

Thanks for the update! I've reviewed your changes and left a few comments. Please take a look when you have a chance.

@@ -50,8 +50,8 @@ pub struct Checkpoint {
/// #[clap(long)]
/// pub pre_dump: bool,
/// TODO: Cgroups mode
Copy link
Copy Markdown
Contributor

@nayuta723 nayuta723 Mar 17, 2026

Choose a reason for hiding this comment

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

I would like to put this on hold until #3455 is merged.

Comment on lines +180 to +196
let temp_dir = match tempfile::tempdir() {
Ok(td) => td,
Err(e) => {
return TestResult::Failed(anyhow::anyhow!(
"failed creating temporary directory {:?}",
e
));
}
};
let image_path = temp_dir.path().join("checkpoint");
if let Err(e) = std::fs::create_dir(&image_path) {
return TestResult::Failed(anyhow::anyhow!(
"failed creating checkpoint directory ({:?}): {}",
&image_path,
e
));
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please refactor the common logic into a shared function. BTW, is it necessary to create the image_path there?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Without specifying image_path, we can't control where CRIU writes the image files, and thus can't inspect them.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I understand that the checkpoint function must have an image_path to operate. If it remains an Option<&Path>, the function should internally generate a default path when None is provided. Alternatively, we could remove the Option and make it a required argument passed from the outside.
I recommend the first approach, as providing a default path internally seems more convenient.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, I will set the default path.

@donkomura donkomura force-pushed the feat-checkpoint-management-cgroups-mode branch 3 times, most recently from 14f60d7 to f8d5158 Compare March 17, 2026 23:54
Copy link
Copy Markdown
Contributor Author

@donkomura donkomura left a comment

Choose a reason for hiding this comment

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

I'm fixing it now. I'll send a review request when it done.

Comment on lines +180 to +196
let temp_dir = match tempfile::tempdir() {
Ok(td) => td,
Err(e) => {
return TestResult::Failed(anyhow::anyhow!(
"failed creating temporary directory {:?}",
e
));
}
};
let image_path = temp_dir.path().join("checkpoint");
if let Err(e) = std::fs::create_dir(&image_path) {
return TestResult::Failed(anyhow::anyhow!(
"failed creating checkpoint directory ({:?}): {}",
&image_path,
e
));
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Without specifying image_path, we can't control where CRIU writes the image files, and thus can't inspect them.

@donkomura donkomura requested a review from nayuta723 March 18, 2026 14:30
@donkomura donkomura force-pushed the feat-checkpoint-management-cgroups-mode branch 4 times, most recently from 38588c2 to f00202b Compare March 20, 2026 15:36
Copy link
Copy Markdown
Contributor

@nayuta723 nayuta723 left a comment

Choose a reason for hiding this comment

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

Apologies for the back-and-forth on my end. I’ve added some nit comments based on the latest implementation strategy. Please check them when you can. Thanks again for your flexibility!

fn checkpoint(
project_path: &Path,
id: &str,
image_path: Option<&Path>,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I’m sorry to backtrack on my previous comment, but I think it’s better to remove the Option after all, as there is processing inside the function that relies on image_path.

Suggested change
image_path: Option<&Path>,
image_path: &Path,

if let Err(e) = setup_network_namespace(project_path, id) {
return e;
}
) -> Result<(), TestResult> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I’m also sorry to backtrack again, but I think it’s better to remove the Result as well. Requiring the caller to handle errors with match every time feels a bit excessive/clunky in this case.

Suggested change
) -> Result<(), TestResult> {
) -> TestResult {

@donkomura donkomura force-pushed the feat-checkpoint-management-cgroups-mode branch 3 times, most recently from 42a3daa to 4a38926 Compare March 26, 2026 15:23
@donkomura
Copy link
Copy Markdown
Contributor Author

Thank you for reviewing, and sorry for the late reply. (I was on vacation.)

@donkomura donkomura requested a review from nayuta723 March 26, 2026 16:32
Copy link
Copy Markdown
Contributor

@nayuta723 nayuta723 left a comment

Choose a reason for hiding this comment

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

LGTM, Thank you for contributions!

"full" => Ok(rust_criu::CgMode::FULL),
"strict" => Ok(rust_criu::CgMode::STRICT),
"soft" => Ok(rust_criu::CgMode::SOFT),
_ => Err(anyhow::anyhow!("manage-cgroup-mode: {s}")),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
_ => Err(anyhow::anyhow!("manage-cgroup-mode: {s}")),
_ => Err(anyhow::anyhow!("invalid manage-cgroups-mode: {s}")),

Alternatively, since this is already validated by clap::builder::PossibleValuesParser, I think the following would also be reasonable.

_ => unreachable!("invalid manage-cgroups-mode: {s}"),

pub shell_job: bool,
pub tcp_established: bool,
pub work_path: Option<PathBuf>,
pub manage_cgroup_mode: rust_criu::CgMode,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Overall, I think manage_cgroup_mode should be renamed to manage_cgroups_mode consistently throughout the codebase.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch, I'll fix it.

@donkomura donkomura force-pushed the feat-checkpoint-management-cgroups-mode branch 2 times, most recently from 75c73a6 to ba14e65 Compare April 1, 2026 15:07
Signed-off-by: donkomura <koiru3822fs@gmail.com>
@donkomura donkomura force-pushed the feat-checkpoint-management-cgroups-mode branch from ba14e65 to 2d23f24 Compare April 1, 2026 15:21
@donkomura donkomura requested a review from saku3 April 1, 2026 17:05
Copy link
Copy Markdown
Member

@saku3 saku3 left a comment

Choose a reason for hiding this comment

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

Thanks!

@saku3 saku3 merged commit 58fc350 into youki-dev:main Apr 1, 2026
42 of 43 checks passed
@github-actions github-actions bot mentioned this pull request Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants