diff --git a/src/cgroups/v2/controller_type.rs b/src/cgroups/v2/controller_type.rs index 016a4064f0..5a0cc22c3e 100644 --- a/src/cgroups/v2/controller_type.rs +++ b/src/cgroups/v2/controller_type.rs @@ -5,6 +5,7 @@ pub enum ControllerType { Memory, HugeTlb, Pids, + Unknown(String), } impl ToString for ControllerType { @@ -16,6 +17,7 @@ impl ToString for ControllerType { Self::Memory => "memory".into(), Self::HugeTlb => "hugetlb".into(), Self::Pids => "pids".into(), + Self::Unknown(tpe) => tpe.into(), } } } diff --git a/src/cgroups/v2/manager.rs b/src/cgroups/v2/manager.rs index 597a644a4d..9903af010b 100644 --- a/src/cgroups/v2/manager.rs +++ b/src/cgroups/v2/manager.rs @@ -4,7 +4,7 @@ use std::{ path::{Path, PathBuf}, }; -use anyhow::{anyhow, Result}; +use anyhow::{bail, Result}; use nix::unistd::Pid; use oci_spec::LinuxResources; @@ -80,10 +80,10 @@ impl Manager { ) -> Result> { let controllers_path = self.root_path.join(cgroup_path).join(CGROUP_CONTROLLERS); if !controllers_path.exists() { - return Err(anyhow!( + bail!( "cannot get available controllers. {:?} does not exist", controllers_path - )); + ) } let mut controllers = Vec::new(); @@ -95,7 +95,7 @@ impl Manager { "io" => controllers.push(ControllerType::Io), "memory" => controllers.push(ControllerType::Memory), "pids" => controllers.push(ControllerType::Pids), - _ => continue, + tpe => controllers.push(ControllerType::Unknown(tpe.to_string())), } } @@ -123,6 +123,10 @@ impl CgroupManager for Manager { ControllerType::Io => Io::apply(linux_resources, &&full_cgroup_path)?, ControllerType::Memory => Memory::apply(linux_resources, &full_cgroup_path)?, ControllerType::Pids => Pids::apply(linux_resources, &&full_cgroup_path)?, + ControllerType::Unknown(tpe) => { + log::warn!("Controller {} is not yet implemented.", tpe); + continue; + } } }