1
0
mirror of https://github.com/containers/youki synced 2024-11-23 09:21:57 +01:00

Add error context to unified controller

This commit is contained in:
Furisto 2021-10-09 22:18:43 +02:00
parent 5b576f39b1
commit ef0ab14d80
2 changed files with 15 additions and 2 deletions

@ -110,7 +110,7 @@ impl CgroupManager for Manager {
if let PseudoControllerType::Unified = pseudoctlr {
Unified::apply(
controller_opt,
&self.cgroup_path,
&self.full_path,
util::get_available_controllers(&self.root_path)?,
)?;
}

@ -1,4 +1,4 @@
use std::path::Path;
use std::{collections::HashMap, path::Path};
use anyhow::{Context, Result};
@ -14,6 +14,19 @@ impl Unified {
controllers: Vec<ControllerType>,
) -> Result<()> {
if let Some(unified) = &controller_opt.resources.unified() {
Self::apply_impl(unified, cgroup_path, &controllers)
.context("failed to apply unified resource restrictions")?;
}
Ok(())
}
fn apply_impl(
unified: &HashMap<String, String>,
cgroup_path: &Path,
controllers: &[ControllerType],
) -> Result<()> {
{
log::debug!("Apply unified cgroup config");
for (cgroup_file, value) in unified {
common::write_cgroup_file_str(cgroup_path.join(cgroup_file), value).map_err(