Merge pull request #1212 from jiangliu/typo

oci: fix a typo in "addtionalGids"
This commit is contained in:
Peng Tao 2020-12-23 18:03:26 +08:00 committed by GitHub
commit 109ab54d63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 24 additions and 50 deletions

3
src/agent/Cargo.lock generated
View File

@ -1198,7 +1198,8 @@ dependencies = [
[[package]] [[package]]
name = "ttrpc" name = "ttrpc"
version = "0.3.0" version = "0.3.0"
source = "git+https://github.com/containerd/ttrpc-rust.git?branch=0.3.0#ba1efe3bbb8f8af4895b7623ed1d11561e70e566" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfa9da24c351f0feef5e66c0b28c18373a7ef3e1bfdfd5852170de494f9bf870"
dependencies = [ dependencies = [
"byteorder", "byteorder",
"libc", "libc",

View File

@ -11,7 +11,7 @@ rustjail = { path = "rustjail" }
protocols = { path = "protocols" } protocols = { path = "protocols" }
netlink = { path = "netlink", features = ["with-log", "with-agent-handler"] } netlink = { path = "netlink", features = ["with-log", "with-agent-handler"] }
lazy_static = "1.3.0" lazy_static = "1.3.0"
ttrpc = { git = "https://github.com/containerd/ttrpc-rust.git", branch="0.3.0" } ttrpc = "0.3.0"
protobuf = "=2.14.0" protobuf = "=2.14.0"
libc = "0.2.58" libc = "0.2.58"
nix = "0.17.0" nix = "0.17.0"

View File

@ -142,7 +142,7 @@ pub struct User {
pub gid: u32, pub gid: u32,
#[serde( #[serde(
default, default,
rename = "addtionalGids", rename = "additionalGids",
skip_serializing_if = "Vec::is_empty" skip_serializing_if = "Vec::is_empty"
)] )]
pub additional_gids: Vec<u32>, pub additional_gids: Vec<u32>,
@ -302,6 +302,7 @@ pub struct LinuxBlockIODevice {
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)] #[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
pub struct LinuxWeightDevice { pub struct LinuxWeightDevice {
#[serde(flatten)]
pub blk: LinuxBlockIODevice, pub blk: LinuxBlockIODevice,
#[serde(default, skip_serializing_if = "Option::is_none")] #[serde(default, skip_serializing_if = "Option::is_none")]
pub weight: Option<u16>, pub weight: Option<u16>,
@ -315,6 +316,7 @@ pub struct LinuxWeightDevice {
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)] #[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
pub struct LinuxThrottleDevice { pub struct LinuxThrottleDevice {
#[serde(flatten)]
pub blk: LinuxBlockIODevice, pub blk: LinuxBlockIODevice,
#[serde(default)] #[serde(default)]
pub rate: u64, pub rate: u64,
@ -375,7 +377,7 @@ pub struct LinuxMemory {
#[serde(default, skip_serializing_if = "Option::is_none", rename = "kernelTCP")] #[serde(default, skip_serializing_if = "Option::is_none", rename = "kernelTCP")]
pub kernel_tcp: Option<i64>, pub kernel_tcp: Option<i64>,
#[serde(default, skip_serializing_if = "Option::is_none")] #[serde(default, skip_serializing_if = "Option::is_none")]
pub swapiness: Option<i64>, pub swappiness: Option<i64>,
#[serde( #[serde(
default, default,
skip_serializing_if = "Option::is_none", skip_serializing_if = "Option::is_none",
@ -833,7 +835,7 @@ mod tests {
} }
#[test] #[test]
fn test_deserialize_sepc() { fn test_deserialize_spec() {
let data = r#"{ let data = r#"{
"ociVersion": "1.0.1", "ociVersion": "1.0.1",
"process": { "process": {
@ -1118,36 +1120,28 @@ mod tests {
"leafWeight": 10, "leafWeight": 10,
"weightDevice": [ "weightDevice": [
{ {
"blk": { "major": 8,
"major": 8, "minor": 0,
"minor": 0
},
"weight": 500, "weight": 500,
"leafWeight": 300 "leafWeight": 300
}, },
{ {
"blk":{ "major": 8,
"major": 8, "minor": 16,
"minor": 16
},
"weight": 500 "weight": 500
} }
], ],
"throttleReadBpsDevice": [ "throttleReadBpsDevice": [
{ {
"blk":{ "major": 8,
"major": 8, "minor": 0,
"minor": 0
},
"rate": 600 "rate": 600
} }
], ],
"throttleWriteIOPSDevice": [ "throttleWriteIOPSDevice": [
{ {
"blk":{ "major": 8,
"major": 8, "minor": 16,
"minor": 16
},
"rate": 300 "rate": 300
} }
] ]
@ -1223,8 +1217,7 @@ mod tests {
uid: 1, uid: 1,
gid: 1, gid: 1,
// incompatible with oci // incompatible with oci
// additional_gids: vec![5, 6], additional_gids: vec![5, 6],
additional_gids: vec![],
username: "".to_string(), username: "".to_string(),
}, },
args: vec!["sh".to_string()], args: vec!["sh".to_string()],
@ -1437,8 +1430,7 @@ mod tests {
swap: Some(536870912), swap: Some(536870912),
kernel: Some(-1), kernel: Some(-1),
kernel_tcp: Some(-1), kernel_tcp: Some(-1),
// incompatible with oci swappiness: Some(0),
swapiness: None,
disable_oom_killer: Some(false), disable_oom_killer: Some(false),
}), }),
cpu: Some(crate::LinuxCPU { cpu: Some(crate::LinuxCPU {
@ -1591,25 +1583,6 @@ mod tests {
vm: None, vm: None,
}; };
// warning : incompatible with oci : https://github.com/opencontainers/runtime-spec/blob/master/config.md
// 1. User use addtionalGids while oci use additionalGids
// 2. LinuxMemory use swapiness while oci use swappiness
// 3. LinuxWeightDevice with blk
// {
// "blk": {
// "major": 8,
// "minor": 0
// },
// "weight": 500,
// "leafWeight": 300
// }
// oci without blk
// {
// "major": 8,
// "minor": 0,
// "weight": 500,
// "leafWeight": 300
// }
let current: crate::Spec = serde_json::from_str(data).unwrap(); let current: crate::Spec = serde_json::from_str(data).unwrap();
assert_eq!(expected, current); assert_eq!(expected, current);
} }

View File

@ -5,7 +5,7 @@ authors = ["The Kata Containers community <kata-dev@lists.katacontainers.io>"]
edition = "2018" edition = "2018"
[dependencies] [dependencies]
ttrpc = { git = "https://github.com/containerd/ttrpc-rust.git", branch="0.3.0" } ttrpc = "0.3.0"
protobuf = "=2.14.0" protobuf = "=2.14.0"
futures = "0.1.27" futures = "0.1.27"

View File

@ -423,13 +423,13 @@ fn set_memory_resources(cg: &cgroups::Cgroup, memory: &LinuxMemory, update: bool
} }
} }
if let Some(swapiness) = memory.swapiness { if let Some(swappiness) = memory.swappiness {
if swapiness >= 0 && swapiness <= 100 { if swappiness >= 0 && swappiness <= 100 {
mem_controller.set_swappiness(swapiness as u64)?; mem_controller.set_swappiness(swappiness as u64)?;
} else { } else {
return Err(anyhow!( return Err(anyhow!(
"invalid value:{}. valid memory swappiness range is 0-100", "invalid value:{}. valid memory swappiness range is 0-100",
swapiness swappiness
)); ));
} }
} }

View File

@ -310,7 +310,7 @@ pub fn resources_grpc_to_oci(res: &grpcLinuxResources) -> ociLinuxResources {
swap: Some(mem.Swap), swap: Some(mem.Swap),
kernel: Some(mem.Kernel), kernel: Some(mem.Kernel),
kernel_tcp: Some(mem.KernelTCP), kernel_tcp: Some(mem.KernelTCP),
swapiness: Some(mem.Swappiness as i64), swappiness: Some(mem.Swappiness as i64),
disable_oom_killer: Some(mem.DisableOOMKiller), disable_oom_killer: Some(mem.DisableOOMKiller),
}) })
} else { } else {