1
0
mirror of https://github.com/kata-containers/kata-containers.git synced 2025-09-03 01:44:29 +00:00

rustjail: print type of cgroup manager

Since the cgroup manager is wrapped in a dyn now, the print in
LinuxContainer::new has been useless and just says "CgroupManager". Extend the
Debug trait for 'dyn Manager' to print the type of the cgroup manager so that
it's easier to debug issues.

Fixes: 
Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
This commit is contained in:
Jeremi Piotrowski
2023-02-10 14:34:53 +01:00
parent 4a35d5fa6e
commit 736aae47a4
4 changed files with 15 additions and 1 deletions
src/agent/rustjail/src/cgroups

@@ -267,6 +267,10 @@ impl CgroupManager for Manager {
fn as_any(&self) -> Result<&dyn Any> {
Ok(self)
}
fn name(&self) -> &str {
"cgroupfs"
}
}
fn set_network_resources(

@@ -66,6 +66,10 @@ impl CgroupManager for Manager {
fn as_any(&self) -> Result<&dyn Any> {
Ok(self)
}
fn name(&self) -> &str {
"mock"
}
}
impl Manager {

@@ -52,10 +52,12 @@ pub trait Manager {
fn as_any(&self) -> Result<&dyn Any> {
Err(anyhow!("not supported!"))
}
fn name(&self) -> &str;
}
impl Debug for dyn Manager + Send + Sync {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "CgroupManager")
write!(f, "{}", self.name())
}
}

@@ -101,6 +101,10 @@ impl CgroupManager for Manager {
fn as_any(&self) -> Result<&dyn Any> {
Ok(self)
}
fn name(&self) -> &str {
"systemd"
}
}
impl Manager {