mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-29 08:47:56 +00:00
runtime-rs: make static resource mgmt idiomatic
Make the get value process (cpu and mem) more idiomatic. Fixes: #4742 Signed-off-by: Ji-Xinyou <jerryji0414@outlook.com>
This commit is contained in:
parent
4a54876dde
commit
00f3a6de12
@ -383,10 +383,7 @@ impl Annotation {
|
||||
let value = self
|
||||
.get_value::<u64>(SANDBOX_CPU_QUOTA_KEY)
|
||||
.unwrap_or(Some(0));
|
||||
if let Some(q) = value {
|
||||
return q;
|
||||
}
|
||||
0
|
||||
value.unwrap_or(0)
|
||||
}
|
||||
|
||||
/// Get the annotation of cpu period for sandbox
|
||||
@ -394,19 +391,13 @@ impl Annotation {
|
||||
let value = self
|
||||
.get_value::<i64>(SANDBOX_CPU_PERIOD_KEY)
|
||||
.unwrap_or(Some(0));
|
||||
if let Some(p) = value {
|
||||
return p;
|
||||
}
|
||||
0
|
||||
value.unwrap_or(0)
|
||||
}
|
||||
|
||||
/// Get the annotation of memory for sandbox
|
||||
pub fn get_sandbox_mem(&self) -> i64 {
|
||||
let value = self.get_value::<i64>(SANDBOX_MEM_KEY).unwrap_or(Some(0));
|
||||
if let Some(m) = value {
|
||||
return m;
|
||||
}
|
||||
0
|
||||
value.unwrap_or(0)
|
||||
}
|
||||
|
||||
/// Get the annotation to specify the Resources.Memory.Swappiness.
|
||||
|
Loading…
Reference in New Issue
Block a user