1
0
Fork 0
mirror of https://github.com/containers/youki synced 2024-06-03 13:26:13 +02:00

Add CFS bandwith burst for cgroup v2

Signed-off-by: Furisto <24721048+Furisto@users.noreply.github.com>
This commit is contained in:
Furisto 2022-04-09 16:00:48 +02:00
parent e0843af203
commit 658a47966b
5 changed files with 29 additions and 13 deletions

15
crates/Cargo.lock generated
View File

@ -429,18 +429,18 @@ dependencies = [
[[package]]
name = "derive_builder"
version = "0.10.2"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d13202debe11181040ae9063d739fa32cfcaaebe2275fe387703460ae2365b30"
checksum = "11d918e7dabe374a51dae0f29d818fece3b218b8b4eabec3bc4d42c537e7ed8f"
dependencies = [
"derive_builder_macro",
]
[[package]]
name = "derive_builder_core"
version = "0.10.2"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66e616858f6187ed828df7c64a6d71720d83767a7f19740b2d1b6fe6327b36e5"
checksum = "f712c2d4e52d5fcae53584e461dcb92fb2202e144ebf83ab0ba4360d18b767c7"
dependencies = [
"darling 0.12.4",
"proc-macro2",
@ -450,9 +450,9 @@ dependencies = [
[[package]]
name = "derive_builder_macro"
version = "0.10.2"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58a94ace95092c5acb1e97a7e846b310cfbd499652f72297da7493f618a98d73"
checksum = "a8a2ac71b4a9a590dde6cee3ca4687aca5e7ce06f4ee297c5a959de5f1e42b2e"
dependencies = [
"derive_builder_core",
"syn",
@ -1285,8 +1285,7 @@ dependencies = [
[[package]]
name = "oci-spec"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71a85b9f9654fe5c3eab8907369250c05aeda9d807b76bd06c740601f881dc02"
source = "git+https://github.com/containers/oci-spec-rs?rev=89376af#89376af909b308e7fa65189f8fccc7cd20468dd1"
dependencies = [
"derive_builder",
"getset",

View File

@ -25,7 +25,7 @@ nix = "0.23.1"
procfs = "0.12.0"
log = "0.4"
anyhow = "1.0"
oci-spec = "0.5.5"
oci-spec = { git = "https://github.com/containers/oci-spec-rs", rev = "89376af" }
dbus = { version = "0.9.5", optional = true }
fixedbitset = "0.4.1"
serde = { version = "1.0", features = ["derive"] }
@ -35,7 +35,7 @@ errno = { version = "0.2.8", optional = true }
libc = { version = "0.2.122", optional = true }
[dev-dependencies]
oci-spec = { version = "0.5.5", features = ["proptests"] }
oci-spec = { git = "https://github.com/containers/oci-spec-rs", rev = "89376af", features = ["proptests"] }
quickcheck = "1"
mockall = { version = "0.11.0", features = [] }
clap = "3.1.8"

View File

@ -12,6 +12,7 @@ use super::controller::Controller;
const CGROUP_CPU_WEIGHT: &str = "cpu.weight";
const CGROUP_CPU_MAX: &str = "cpu.max";
const CGROUP_CPU_BURST: &str = "cpu.max.burst";
const UNRESTRICTED_QUOTA: &str = "max";
const MAX_CPU_WEIGHT: u64 = 10000;
@ -91,6 +92,10 @@ impl Cpu {
common::write_cgroup_file_str(&cpu_max_file, &cpu_max)?;
}
if let Some(burst) = cpu.burst() {
common::write_cgroup_file(path.join(CGROUP_CPU_BURST), burst)?;
}
Ok(())
}
@ -274,4 +279,16 @@ mod tests {
assert_eq!(actual, expected);
}
#[test]
fn test_burst() {
let expected = 100000u64;
let (tmp, burst_file) = setup("test_burst", CGROUP_CPU_BURST);
let cpu = LinuxCpuBuilder::default().burst(expected).build().unwrap();
Cpu::apply(&tmp, &cpu).expect("apply cpu");
let actual = fs::read_to_string(burst_file).expect("read burst file");
assert_eq!(actual, expected.to_string());
}
}

View File

@ -29,7 +29,7 @@ libc = "0.2.122"
log = "0.4"
mio = { version = "0.8.2", features = ["os-ext", "os-poll"] }
nix = "0.23.1"
oci-spec = "0.5.5"
oci-spec = { git = "https://github.com/containers/oci-spec-rs", rev = "89376af" }
path-clean = "0.1.0"
procfs = "0.12.0"
prctl = "1.0.0"
@ -43,7 +43,7 @@ wasmer = { version = "2.2.0", optional = true }
wasmer-wasi = { version = "2.2.0", optional = true }
[dev-dependencies]
oci-spec = { version = "0.5.5", features = ["proptests"] }
oci-spec = { git = "https://github.com/containers/oci-spec-rs", rev = "89376af", features = ["proptests"] }
quickcheck = "1"
serial_test = "0.6.0"
rand = "0.8.5"

View File

@ -25,7 +25,7 @@ libcontainer = { version = "0.0.3", path = "../libcontainer" }
liboci-cli = { version = "0.0.3", path = "../liboci-cli" }
log = { version = "0.4", features = ["std"]}
nix = "0.23.1"
oci-spec = "0.5.5"
oci-spec = { git = "https://github.com/containers/oci-spec-rs", rev = "89376af" }
once_cell = "1.10.0"
pentacle = "1.0.0"
procfs = "0.12.0"