1
0
Fork 0
mirror of https://github.com/containers/youki synced 2024-06-02 12:56:16 +02:00

Follow runc's behavior when setting cpu.max

Runc interprets a a zero quota value as unrestricted.
This commit is contained in:
Furisto 2021-12-27 18:19:32 +01:00
parent e43f400d88
commit dbe2155bca

View File

@ -72,12 +72,12 @@ impl Cpu {
let cpu_max_file = path.join(CGROUP_CPU_MAX);
let new_cpu_max: Option<Cow<str>> = match (cpu.quota(), cpu.period()) {
(None, Some(period)) => Self::create_period_only_value(&cpu_max_file, period)?,
(Some(quota), None) if quota >= 0 => Some(quota.to_string().into()),
(Some(quota), None) if quota < 0 => Some(UNRESTRICTED_QUOTA.into()),
(Some(quota), Some(period)) if quota >= 0 => {
(Some(quota), None) if quota > 0 => Some(quota.to_string().into()),
(Some(quota), None) if quota <= 0 => Some(UNRESTRICTED_QUOTA.into()),
(Some(quota), Some(period)) if quota > 0 => {
Some(format!("{} {}", quota, period).into())
}
(Some(quota), Some(period)) if quota < 0 => {
(Some(quota), Some(period)) if quota <= 0 => {
Some(format!("{} {}", UNRESTRICTED_QUOTA, period).into())
}
_ => None,