mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-13 21:56:32 +00:00
agent: Bump ttrpc from 0.6.0 to 0.7.1
Fixes: #6646 Signed-off-by: Tim Zhang <tim@hyper.sh>
This commit is contained in:
parent
009b42dbff
commit
8af6fc77cd
87
src/agent/Cargo.lock
generated
87
src/agent/Cargo.lock
generated
@ -819,7 +819,7 @@ dependencies = [
|
|||||||
"opentelemetry",
|
"opentelemetry",
|
||||||
"procfs",
|
"procfs",
|
||||||
"prometheus",
|
"prometheus",
|
||||||
"protobuf",
|
"protobuf 3.2.0",
|
||||||
"protocols",
|
"protocols",
|
||||||
"regex",
|
"regex",
|
||||||
"rtnetlink",
|
"rtnetlink",
|
||||||
@ -1431,7 +1431,7 @@ dependencies = [
|
|||||||
"memchr",
|
"memchr",
|
||||||
"parking_lot 0.12.1",
|
"parking_lot 0.12.1",
|
||||||
"procfs",
|
"procfs",
|
||||||
"protobuf",
|
"protobuf 2.27.1",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -1491,9 +1491,16 @@ name = "protobuf"
|
|||||||
version = "2.27.1"
|
version = "2.27.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cf7e6d18738ecd0902d30d1ad232c9125985a3422929b16c65517b38adc14f96"
|
checksum = "cf7e6d18738ecd0902d30d1ad232c9125985a3422929b16c65517b38adc14f96"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "protobuf"
|
||||||
|
version = "3.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b55bad9126f378a853655831eb7363b7b01b81d19f8cb1218861086ca4a1a61e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"once_cell",
|
||||||
"serde_derive",
|
"protobuf-support",
|
||||||
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1502,17 +1509,47 @@ version = "2.27.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "aec1632b7c8f2e620343439a7dfd1f3c47b18906c4be58982079911482b5d707"
|
checksum = "aec1632b7c8f2e620343439a7dfd1f3c47b18906c4be58982079911482b5d707"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"protobuf",
|
"protobuf 2.27.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "protobuf-codegen-pure"
|
name = "protobuf-codegen"
|
||||||
version = "2.27.1"
|
version = "3.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9f8122fdb18e55190c796b088a16bdb70cd7acdcd48f7a8b796b58c62e532cc6"
|
checksum = "0dd418ac3c91caa4032d37cb80ff0d44e2ebe637b2fb243b6234bf89cdac4901"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"protobuf",
|
"anyhow",
|
||||||
"protobuf-codegen",
|
"once_cell",
|
||||||
|
"protobuf 3.2.0",
|
||||||
|
"protobuf-parse",
|
||||||
|
"regex",
|
||||||
|
"tempfile",
|
||||||
|
"thiserror",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "protobuf-parse"
|
||||||
|
version = "3.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9d39b14605eaa1f6a340aec7f320b34064feb26c93aec35d6a9a2272a8ddfa49"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"indexmap",
|
||||||
|
"log",
|
||||||
|
"protobuf 3.2.0",
|
||||||
|
"protobuf-support",
|
||||||
|
"tempfile",
|
||||||
|
"thiserror",
|
||||||
|
"which",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "protobuf-support"
|
||||||
|
version = "3.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a5d4d7b8601c814cfb36bcebb79f0e61e45e1e93640cf778837833bbed05c372"
|
||||||
|
dependencies = [
|
||||||
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1521,7 +1558,7 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"oci",
|
"oci",
|
||||||
"protobuf",
|
"protobuf 3.2.0",
|
||||||
"ttrpc",
|
"ttrpc",
|
||||||
"ttrpc-codegen",
|
"ttrpc-codegen",
|
||||||
]
|
]
|
||||||
@ -1705,7 +1742,7 @@ dependencies = [
|
|||||||
"nix 0.24.2",
|
"nix 0.24.2",
|
||||||
"oci",
|
"oci",
|
||||||
"path-absolutize",
|
"path-absolutize",
|
||||||
"protobuf",
|
"protobuf 3.2.0",
|
||||||
"protocols",
|
"protocols",
|
||||||
"regex",
|
"regex",
|
||||||
"rlimit",
|
"rlimit",
|
||||||
@ -2217,9 +2254,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ttrpc"
|
name = "ttrpc"
|
||||||
version = "0.6.1"
|
version = "0.7.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2ecfff459a859c6ba6668ff72b34c2f1d94d9d58f7088414c2674ad0f31cc7d8"
|
checksum = "a35f22a2964bea14afee161665bb260b83cb48e665e0260ca06ec0e775c8b06c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
@ -2227,8 +2264,8 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
"nix 0.23.1",
|
"nix 0.23.1",
|
||||||
"protobuf",
|
"protobuf 3.2.0",
|
||||||
"protobuf-codegen-pure",
|
"protobuf-codegen 3.2.0",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-vsock",
|
"tokio-vsock",
|
||||||
@ -2236,28 +2273,28 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ttrpc-codegen"
|
name = "ttrpc-codegen"
|
||||||
version = "0.2.0"
|
version = "0.4.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "809eda4e459820237104e4b61d6b41bbe6c9e1ce6adf4057955e6e6722a90408"
|
checksum = "94d7f7631d7a9ebed715a47cd4cb6072cbc7ae1d4ec01598971bbec0024340c2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"protobuf",
|
"protobuf 2.27.1",
|
||||||
"protobuf-codegen",
|
"protobuf-codegen 3.2.0",
|
||||||
"protobuf-codegen-pure",
|
"protobuf-support",
|
||||||
"ttrpc-compiler",
|
"ttrpc-compiler",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ttrpc-compiler"
|
name = "ttrpc-compiler"
|
||||||
version = "0.4.1"
|
version = "0.6.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2978ed3fa047d8fd55cbeb4d4a61d461fb3021a90c9618519c73ce7e5bb66c15"
|
checksum = "ec3cb5dbf1f0865a34fe3f722290fe776cacb16f50428610b779467b76ddf647"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"derive-new",
|
"derive-new",
|
||||||
"prost",
|
"prost",
|
||||||
"prost-build",
|
"prost-build",
|
||||||
"prost-types",
|
"prost-types",
|
||||||
"protobuf",
|
"protobuf 2.27.1",
|
||||||
"protobuf-codegen",
|
"protobuf-codegen 2.27.1",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -10,8 +10,8 @@ oci = { path = "../libs/oci" }
|
|||||||
rustjail = { path = "rustjail" }
|
rustjail = { path = "rustjail" }
|
||||||
protocols = { path = "../libs/protocols", features = ["async"] }
|
protocols = { path = "../libs/protocols", features = ["async"] }
|
||||||
lazy_static = "1.3.0"
|
lazy_static = "1.3.0"
|
||||||
ttrpc = { version = "0.6.0", features = ["async"], default-features = false }
|
ttrpc = { version = "0.7.1", features = ["async"], default-features = false }
|
||||||
protobuf = "2.27.0"
|
protobuf = "3.2.0"
|
||||||
libc = "0.2.58"
|
libc = "0.2.58"
|
||||||
nix = "0.24.2"
|
nix = "0.24.2"
|
||||||
capctl = "0.2.0"
|
capctl = "0.2.0"
|
||||||
|
@ -18,7 +18,7 @@ scopeguard = "1.0.0"
|
|||||||
capctl = "0.2.0"
|
capctl = "0.2.0"
|
||||||
lazy_static = "1.3.0"
|
lazy_static = "1.3.0"
|
||||||
libc = "0.2.58"
|
libc = "0.2.58"
|
||||||
protobuf = "2.27.0"
|
protobuf = "3.2.0"
|
||||||
slog = "2.5.2"
|
slog = "2.5.2"
|
||||||
slog-scope = "4.1.2"
|
slog-scope = "4.1.2"
|
||||||
scan_fmt = "0.2.6"
|
scan_fmt = "0.2.6"
|
||||||
|
@ -27,7 +27,7 @@ use oci::{
|
|||||||
LinuxNetwork, LinuxPids, LinuxResources,
|
LinuxNetwork, LinuxPids, LinuxResources,
|
||||||
};
|
};
|
||||||
|
|
||||||
use protobuf::{CachedSize, RepeatedField, SingularPtrField, UnknownFields};
|
use protobuf::MessageField;
|
||||||
use protocols::agent::{
|
use protocols::agent::{
|
||||||
BlkioStats, BlkioStatsEntry, CgroupStats, CpuStats, CpuUsage, HugetlbStats, MemoryData,
|
BlkioStats, BlkioStatsEntry, CgroupStats, CpuStats, CpuUsage, HugetlbStats, MemoryData,
|
||||||
MemoryStats, PidsStats, ThrottlingData,
|
MemoryStats, PidsStats, ThrottlingData,
|
||||||
@ -50,7 +50,7 @@ macro_rules! get_controller_or_return_singular_none {
|
|||||||
($cg:ident) => {
|
($cg:ident) => {
|
||||||
match $cg.controller_of() {
|
match $cg.controller_of() {
|
||||||
Some(c) => c,
|
Some(c) => c,
|
||||||
None => return SingularPtrField::none(),
|
None => return MessageField::none(),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -134,11 +134,10 @@ impl CgroupManager for Manager {
|
|||||||
|
|
||||||
let throttling_data = get_cpu_stats(&self.cgroup);
|
let throttling_data = get_cpu_stats(&self.cgroup);
|
||||||
|
|
||||||
let cpu_stats = SingularPtrField::some(CpuStats {
|
let cpu_stats = MessageField::some(CpuStats {
|
||||||
cpu_usage,
|
cpu_usage,
|
||||||
throttling_data,
|
throttling_data,
|
||||||
unknown_fields: UnknownFields::default(),
|
..Default::default()
|
||||||
cached_size: CachedSize::default(),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Memorystats
|
// Memorystats
|
||||||
@ -160,8 +159,7 @@ impl CgroupManager for Manager {
|
|||||||
pids_stats,
|
pids_stats,
|
||||||
blkio_stats,
|
blkio_stats,
|
||||||
hugetlb_stats,
|
hugetlb_stats,
|
||||||
unknown_fields: UnknownFields::default(),
|
..Default::default()
|
||||||
cached_size: CachedSize::default(),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,14 +444,14 @@ fn set_memory_resources(cg: &cgroups::Cgroup, memory: &LinuxMemory, update: bool
|
|||||||
let memstat = get_memory_stats(cg)
|
let memstat = get_memory_stats(cg)
|
||||||
.into_option()
|
.into_option()
|
||||||
.ok_or_else(|| anyhow!("failed to get the cgroup memory stats"))?;
|
.ok_or_else(|| anyhow!("failed to get the cgroup memory stats"))?;
|
||||||
let memusage = memstat.get_usage();
|
let memusage = memstat.usage();
|
||||||
|
|
||||||
// When update memory limit, the kernel would check the current memory limit
|
// When update memory limit, the kernel would check the current memory limit
|
||||||
// set against the new swap setting, if the current memory limit is large than
|
// set against the new swap setting, if the current memory limit is large than
|
||||||
// the new swap, then set limit first, otherwise the kernel would complain and
|
// the new swap, then set limit first, otherwise the kernel would complain and
|
||||||
// refused to set; on the other hand, if the current memory limit is smaller than
|
// refused to set; on the other hand, if the current memory limit is smaller than
|
||||||
// the new swap, then we should set the swap first and then set the memor limit.
|
// the new swap, then we should set the swap first and then set the memor limit.
|
||||||
if swap == -1 || memusage.get_limit() < swap as u64 {
|
if swap == -1 || memusage.limit() < swap as u64 {
|
||||||
mem_controller.set_memswap_limit(swap)?;
|
mem_controller.set_memswap_limit(swap)?;
|
||||||
set_resource!(mem_controller, set_limit, memory, limit);
|
set_resource!(mem_controller, set_limit, memory, limit);
|
||||||
} else {
|
} else {
|
||||||
@ -657,21 +655,20 @@ lazy_static! {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_cpu_stats(cg: &cgroups::Cgroup) -> SingularPtrField<ThrottlingData> {
|
fn get_cpu_stats(cg: &cgroups::Cgroup) -> MessageField<ThrottlingData> {
|
||||||
let cpu_controller: &CpuController = get_controller_or_return_singular_none!(cg);
|
let cpu_controller: &CpuController = get_controller_or_return_singular_none!(cg);
|
||||||
let stat = cpu_controller.cpu().stat;
|
let stat = cpu_controller.cpu().stat;
|
||||||
let h = lines_to_map(&stat);
|
let h = lines_to_map(&stat);
|
||||||
|
|
||||||
SingularPtrField::some(ThrottlingData {
|
MessageField::some(ThrottlingData {
|
||||||
periods: *h.get("nr_periods").unwrap_or(&0),
|
periods: *h.get("nr_periods").unwrap_or(&0),
|
||||||
throttled_periods: *h.get("nr_throttled").unwrap_or(&0),
|
throttled_periods: *h.get("nr_throttled").unwrap_or(&0),
|
||||||
throttled_time: *h.get("throttled_time").unwrap_or(&0),
|
throttled_time: *h.get("throttled_time").unwrap_or(&0),
|
||||||
unknown_fields: UnknownFields::default(),
|
..Default::default()
|
||||||
cached_size: CachedSize::default(),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_cpuacct_stats(cg: &cgroups::Cgroup) -> SingularPtrField<CpuUsage> {
|
fn get_cpuacct_stats(cg: &cgroups::Cgroup) -> MessageField<CpuUsage> {
|
||||||
if let Some(cpuacct_controller) = cg.controller_of::<CpuAcctController>() {
|
if let Some(cpuacct_controller) = cg.controller_of::<CpuAcctController>() {
|
||||||
let cpuacct = cpuacct_controller.cpuacct();
|
let cpuacct = cpuacct_controller.cpuacct();
|
||||||
|
|
||||||
@ -685,13 +682,12 @@ fn get_cpuacct_stats(cg: &cgroups::Cgroup) -> SingularPtrField<CpuUsage> {
|
|||||||
|
|
||||||
let percpu_usage = line_to_vec(&cpuacct.usage_percpu);
|
let percpu_usage = line_to_vec(&cpuacct.usage_percpu);
|
||||||
|
|
||||||
return SingularPtrField::some(CpuUsage {
|
return MessageField::some(CpuUsage {
|
||||||
total_usage,
|
total_usage,
|
||||||
percpu_usage,
|
percpu_usage,
|
||||||
usage_in_kernelmode,
|
usage_in_kernelmode,
|
||||||
usage_in_usermode,
|
usage_in_usermode,
|
||||||
unknown_fields: UnknownFields::default(),
|
..Default::default()
|
||||||
cached_size: CachedSize::default(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -704,17 +700,16 @@ fn get_cpuacct_stats(cg: &cgroups::Cgroup) -> SingularPtrField<CpuUsage> {
|
|||||||
let total_usage = *h.get("usage_usec").unwrap_or(&0);
|
let total_usage = *h.get("usage_usec").unwrap_or(&0);
|
||||||
let percpu_usage = vec![];
|
let percpu_usage = vec![];
|
||||||
|
|
||||||
SingularPtrField::some(CpuUsage {
|
MessageField::some(CpuUsage {
|
||||||
total_usage,
|
total_usage,
|
||||||
percpu_usage,
|
percpu_usage,
|
||||||
usage_in_kernelmode,
|
usage_in_kernelmode,
|
||||||
usage_in_usermode,
|
usage_in_usermode,
|
||||||
unknown_fields: UnknownFields::default(),
|
..Default::default()
|
||||||
cached_size: CachedSize::default(),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_memory_stats(cg: &cgroups::Cgroup) -> SingularPtrField<MemoryStats> {
|
fn get_memory_stats(cg: &cgroups::Cgroup) -> MessageField<MemoryStats> {
|
||||||
let memory_controller: &MemController = get_controller_or_return_singular_none!(cg);
|
let memory_controller: &MemController = get_controller_or_return_singular_none!(cg);
|
||||||
|
|
||||||
// cache from memory stat
|
// cache from memory stat
|
||||||
@ -726,52 +721,48 @@ fn get_memory_stats(cg: &cgroups::Cgroup) -> SingularPtrField<MemoryStats> {
|
|||||||
let use_hierarchy = value == 1;
|
let use_hierarchy = value == 1;
|
||||||
|
|
||||||
// get memory data
|
// get memory data
|
||||||
let usage = SingularPtrField::some(MemoryData {
|
let usage = MessageField::some(MemoryData {
|
||||||
usage: memory.usage_in_bytes,
|
usage: memory.usage_in_bytes,
|
||||||
max_usage: memory.max_usage_in_bytes,
|
max_usage: memory.max_usage_in_bytes,
|
||||||
failcnt: memory.fail_cnt,
|
failcnt: memory.fail_cnt,
|
||||||
limit: memory.limit_in_bytes as u64,
|
limit: memory.limit_in_bytes as u64,
|
||||||
unknown_fields: UnknownFields::default(),
|
..Default::default()
|
||||||
cached_size: CachedSize::default(),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// get swap usage
|
// get swap usage
|
||||||
let memswap = memory_controller.memswap();
|
let memswap = memory_controller.memswap();
|
||||||
|
|
||||||
let swap_usage = SingularPtrField::some(MemoryData {
|
let swap_usage = MessageField::some(MemoryData {
|
||||||
usage: memswap.usage_in_bytes,
|
usage: memswap.usage_in_bytes,
|
||||||
max_usage: memswap.max_usage_in_bytes,
|
max_usage: memswap.max_usage_in_bytes,
|
||||||
failcnt: memswap.fail_cnt,
|
failcnt: memswap.fail_cnt,
|
||||||
limit: memswap.limit_in_bytes as u64,
|
limit: memswap.limit_in_bytes as u64,
|
||||||
unknown_fields: UnknownFields::default(),
|
..Default::default()
|
||||||
cached_size: CachedSize::default(),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// get kernel usage
|
// get kernel usage
|
||||||
let kmem_stat = memory_controller.kmem_stat();
|
let kmem_stat = memory_controller.kmem_stat();
|
||||||
|
|
||||||
let kernel_usage = SingularPtrField::some(MemoryData {
|
let kernel_usage = MessageField::some(MemoryData {
|
||||||
usage: kmem_stat.usage_in_bytes,
|
usage: kmem_stat.usage_in_bytes,
|
||||||
max_usage: kmem_stat.max_usage_in_bytes,
|
max_usage: kmem_stat.max_usage_in_bytes,
|
||||||
failcnt: kmem_stat.fail_cnt,
|
failcnt: kmem_stat.fail_cnt,
|
||||||
limit: kmem_stat.limit_in_bytes as u64,
|
limit: kmem_stat.limit_in_bytes as u64,
|
||||||
unknown_fields: UnknownFields::default(),
|
..Default::default()
|
||||||
cached_size: CachedSize::default(),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
SingularPtrField::some(MemoryStats {
|
MessageField::some(MemoryStats {
|
||||||
cache,
|
cache,
|
||||||
usage,
|
usage,
|
||||||
swap_usage,
|
swap_usage,
|
||||||
kernel_usage,
|
kernel_usage,
|
||||||
use_hierarchy,
|
use_hierarchy,
|
||||||
stats: memory.stat.raw,
|
stats: memory.stat.raw,
|
||||||
unknown_fields: UnknownFields::default(),
|
..Default::default()
|
||||||
cached_size: CachedSize::default(),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_pids_stats(cg: &cgroups::Cgroup) -> SingularPtrField<PidsStats> {
|
fn get_pids_stats(cg: &cgroups::Cgroup) -> MessageField<PidsStats> {
|
||||||
let pid_controller: &PidController = get_controller_or_return_singular_none!(cg);
|
let pid_controller: &PidController = get_controller_or_return_singular_none!(cg);
|
||||||
|
|
||||||
let current = pid_controller.get_pid_current().unwrap_or(0);
|
let current = pid_controller.get_pid_current().unwrap_or(0);
|
||||||
@ -785,11 +776,10 @@ fn get_pids_stats(cg: &cgroups::Cgroup) -> SingularPtrField<PidsStats> {
|
|||||||
},
|
},
|
||||||
} as u64;
|
} as u64;
|
||||||
|
|
||||||
SingularPtrField::some(PidsStats {
|
MessageField::some(PidsStats {
|
||||||
current,
|
current,
|
||||||
limit,
|
limit,
|
||||||
unknown_fields: UnknownFields::default(),
|
..Default::default()
|
||||||
cached_size: CachedSize::default(),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -825,8 +815,8 @@ https://github.com/opencontainers/runc/blob/a5847db387ae28c0ca4ebe4beee1a76900c8
|
|||||||
Total 0
|
Total 0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fn get_blkio_stat_blkiodata(blkiodata: &[BlkIoData]) -> RepeatedField<BlkioStatsEntry> {
|
fn get_blkio_stat_blkiodata(blkiodata: &[BlkIoData]) -> Vec<BlkioStatsEntry> {
|
||||||
let mut m = RepeatedField::new();
|
let mut m = Vec::new();
|
||||||
if blkiodata.is_empty() {
|
if blkiodata.is_empty() {
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
@ -839,16 +829,15 @@ fn get_blkio_stat_blkiodata(blkiodata: &[BlkIoData]) -> RepeatedField<BlkioStats
|
|||||||
minor: d.minor as u64,
|
minor: d.minor as u64,
|
||||||
op: op.clone(),
|
op: op.clone(),
|
||||||
value: d.data,
|
value: d.data,
|
||||||
unknown_fields: UnknownFields::default(),
|
..Default::default()
|
||||||
cached_size: CachedSize::default(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
m
|
m
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_blkio_stat_ioservice(services: &[IoService]) -> RepeatedField<BlkioStatsEntry> {
|
fn get_blkio_stat_ioservice(services: &[IoService]) -> Vec<BlkioStatsEntry> {
|
||||||
let mut m = RepeatedField::new();
|
let mut m = Vec::new();
|
||||||
|
|
||||||
if services.is_empty() {
|
if services.is_empty() {
|
||||||
return m;
|
return m;
|
||||||
@ -872,17 +861,16 @@ fn build_blkio_stats_entry(major: i16, minor: i16, op: &str, value: u64) -> Blki
|
|||||||
minor: minor as u64,
|
minor: minor as u64,
|
||||||
op: op.to_string(),
|
op: op.to_string(),
|
||||||
value,
|
value,
|
||||||
unknown_fields: UnknownFields::default(),
|
..Default::default()
|
||||||
cached_size: CachedSize::default(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_blkio_stats_v2(cg: &cgroups::Cgroup) -> SingularPtrField<BlkioStats> {
|
fn get_blkio_stats_v2(cg: &cgroups::Cgroup) -> MessageField<BlkioStats> {
|
||||||
let blkio_controller: &BlkIoController = get_controller_or_return_singular_none!(cg);
|
let blkio_controller: &BlkIoController = get_controller_or_return_singular_none!(cg);
|
||||||
let blkio = blkio_controller.blkio();
|
let blkio = blkio_controller.blkio();
|
||||||
|
|
||||||
let mut resp = BlkioStats::new();
|
let mut resp = BlkioStats::new();
|
||||||
let mut blkio_stats = RepeatedField::new();
|
let mut blkio_stats = Vec::new();
|
||||||
|
|
||||||
let stat = blkio.io_stat;
|
let stat = blkio.io_stat;
|
||||||
for s in stat {
|
for s in stat {
|
||||||
@ -898,10 +886,10 @@ fn get_blkio_stats_v2(cg: &cgroups::Cgroup) -> SingularPtrField<BlkioStats> {
|
|||||||
|
|
||||||
resp.io_service_bytes_recursive = blkio_stats;
|
resp.io_service_bytes_recursive = blkio_stats;
|
||||||
|
|
||||||
SingularPtrField::some(resp)
|
MessageField::some(resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_blkio_stats(cg: &cgroups::Cgroup) -> SingularPtrField<BlkioStats> {
|
fn get_blkio_stats(cg: &cgroups::Cgroup) -> MessageField<BlkioStats> {
|
||||||
if cg.v2() {
|
if cg.v2() {
|
||||||
return get_blkio_stats_v2(cg);
|
return get_blkio_stats_v2(cg);
|
||||||
}
|
}
|
||||||
@ -934,7 +922,7 @@ fn get_blkio_stats(cg: &cgroups::Cgroup) -> SingularPtrField<BlkioStats> {
|
|||||||
m.sectors_recursive = get_blkio_stat_blkiodata(&blkio.sectors_recursive);
|
m.sectors_recursive = get_blkio_stat_blkiodata(&blkio.sectors_recursive);
|
||||||
}
|
}
|
||||||
|
|
||||||
SingularPtrField::some(m)
|
MessageField::some(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_hugetlb_stats(cg: &cgroups::Cgroup) -> HashMap<String, HugetlbStats> {
|
fn get_hugetlb_stats(cg: &cgroups::Cgroup) -> HashMap<String, HugetlbStats> {
|
||||||
@ -958,8 +946,7 @@ fn get_hugetlb_stats(cg: &cgroups::Cgroup) -> HashMap<String, HugetlbStats> {
|
|||||||
usage,
|
usage,
|
||||||
max_usage,
|
max_usage,
|
||||||
failcnt,
|
failcnt,
|
||||||
unknown_fields: UnknownFields::default(),
|
..Default::default()
|
||||||
cached_size: CachedSize::default(),
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
//
|
//
|
||||||
|
|
||||||
use protobuf::{CachedSize, SingularPtrField, UnknownFields};
|
use protobuf::MessageField;
|
||||||
|
|
||||||
use crate::cgroups::Manager as CgroupManager;
|
use crate::cgroups::Manager as CgroupManager;
|
||||||
use crate::protocols::agent::{BlkioStats, CgroupStats, CpuStats, MemoryStats, PidsStats};
|
use crate::protocols::agent::{BlkioStats, CgroupStats, CpuStats, MemoryStats, PidsStats};
|
||||||
@ -33,13 +33,12 @@ impl CgroupManager for Manager {
|
|||||||
|
|
||||||
fn get_stats(&self) -> Result<CgroupStats> {
|
fn get_stats(&self) -> Result<CgroupStats> {
|
||||||
Ok(CgroupStats {
|
Ok(CgroupStats {
|
||||||
cpu_stats: SingularPtrField::some(CpuStats::default()),
|
cpu_stats: MessageField::some(CpuStats::default()),
|
||||||
memory_stats: SingularPtrField::some(MemoryStats::new()),
|
memory_stats: MessageField::some(MemoryStats::new()),
|
||||||
pids_stats: SingularPtrField::some(PidsStats::new()),
|
pids_stats: MessageField::some(PidsStats::new()),
|
||||||
blkio_stats: SingularPtrField::some(BlkioStats::new()),
|
blkio_stats: MessageField::some(BlkioStats::new()),
|
||||||
hugetlb_stats: HashMap::new(),
|
hugetlb_stats: HashMap::new(),
|
||||||
unknown_fields: UnknownFields::default(),
|
..Default::default()
|
||||||
cached_size: CachedSize::default(),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ use nix::unistd::{self, fork, ForkResult, Gid, Pid, Uid, User};
|
|||||||
use std::os::unix::fs::MetadataExt;
|
use std::os::unix::fs::MetadataExt;
|
||||||
use std::os::unix::io::AsRawFd;
|
use std::os::unix::io::AsRawFd;
|
||||||
|
|
||||||
use protobuf::SingularPtrField;
|
use protobuf::MessageField;
|
||||||
|
|
||||||
use oci::State as OCIState;
|
use oci::State as OCIState;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
@ -875,7 +875,7 @@ impl BaseContainer for LinuxContainer {
|
|||||||
// what about network interface stats?
|
// what about network interface stats?
|
||||||
|
|
||||||
Ok(StatsContainerResponse {
|
Ok(StatsContainerResponse {
|
||||||
cgroup_stats: SingularPtrField::some(self.cgroup_manager.as_ref().get_stats()?),
|
cgroup_stats: MessageField::some(self.cgroup_manager.as_ref().get_stats()?),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -82,11 +82,11 @@ pub fn process_grpc_to_oci(p: &grpc::Process) -> oci::Process {
|
|||||||
let cap = p.Capabilities.as_ref().unwrap();
|
let cap = p.Capabilities.as_ref().unwrap();
|
||||||
|
|
||||||
Some(oci::LinuxCapabilities {
|
Some(oci::LinuxCapabilities {
|
||||||
bounding: cap.Bounding.clone().into_vec(),
|
bounding: cap.Bounding.clone(),
|
||||||
effective: cap.Effective.clone().into_vec(),
|
effective: cap.Effective.clone(),
|
||||||
inheritable: cap.Inheritable.clone().into_vec(),
|
inheritable: cap.Inheritable.clone(),
|
||||||
permitted: cap.Permitted.clone().into_vec(),
|
permitted: cap.Permitted.clone(),
|
||||||
ambient: cap.Ambient.clone().into_vec(),
|
ambient: cap.Ambient.clone(),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
@ -108,8 +108,8 @@ pub fn process_grpc_to_oci(p: &grpc::Process) -> oci::Process {
|
|||||||
terminal: p.Terminal,
|
terminal: p.Terminal,
|
||||||
console_size,
|
console_size,
|
||||||
user,
|
user,
|
||||||
args: p.Args.clone().into_vec(),
|
args: p.Args.clone(),
|
||||||
env: p.Env.clone().into_vec(),
|
env: p.Env.clone(),
|
||||||
cwd: p.Cwd.clone(),
|
cwd: p.Cwd.clone(),
|
||||||
capabilities,
|
capabilities,
|
||||||
rlimits,
|
rlimits,
|
||||||
@ -130,9 +130,9 @@ fn root_grpc_to_oci(root: &grpc::Root) -> oci::Root {
|
|||||||
fn mount_grpc_to_oci(m: &grpc::Mount) -> oci::Mount {
|
fn mount_grpc_to_oci(m: &grpc::Mount) -> oci::Mount {
|
||||||
oci::Mount {
|
oci::Mount {
|
||||||
destination: m.destination.clone(),
|
destination: m.destination.clone(),
|
||||||
r#type: m.field_type.clone(),
|
r#type: m.type_.clone(),
|
||||||
source: m.source.clone(),
|
source: m.source.clone(),
|
||||||
options: m.options.clone().into_vec(),
|
options: m.options.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,8 +143,8 @@ fn hook_grpc_to_oci(h: &[grpcHook]) -> Vec<oci::Hook> {
|
|||||||
for e in h.iter() {
|
for e in h.iter() {
|
||||||
r.push(oci::Hook {
|
r.push(oci::Hook {
|
||||||
path: e.Path.clone(),
|
path: e.Path.clone(),
|
||||||
args: e.Args.clone().into_vec(),
|
args: e.Args.clone(),
|
||||||
env: e.Env.clone().into_vec(),
|
env: e.Env.clone(),
|
||||||
timeout: Some(e.Timeout as i32),
|
timeout: Some(e.Timeout as i32),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -359,7 +359,7 @@ fn seccomp_grpc_to_oci(sec: &grpc::LinuxSeccomp) -> oci::LinuxSeccomp {
|
|||||||
let mut args = Vec::new();
|
let mut args = Vec::new();
|
||||||
|
|
||||||
let errno_ret: u32 = if sys.has_errnoret() {
|
let errno_ret: u32 = if sys.has_errnoret() {
|
||||||
sys.get_errnoret()
|
sys.errnoret()
|
||||||
} else {
|
} else {
|
||||||
libc::EPERM as u32
|
libc::EPERM as u32
|
||||||
};
|
};
|
||||||
@ -374,7 +374,7 @@ fn seccomp_grpc_to_oci(sec: &grpc::LinuxSeccomp) -> oci::LinuxSeccomp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
r.push(oci::LinuxSyscall {
|
r.push(oci::LinuxSyscall {
|
||||||
names: sys.Names.clone().into_vec(),
|
names: sys.Names.clone(),
|
||||||
action: sys.Action.clone(),
|
action: sys.Action.clone(),
|
||||||
errno_ret,
|
errno_ret,
|
||||||
args,
|
args,
|
||||||
@ -385,8 +385,8 @@ fn seccomp_grpc_to_oci(sec: &grpc::LinuxSeccomp) -> oci::LinuxSeccomp {
|
|||||||
|
|
||||||
oci::LinuxSeccomp {
|
oci::LinuxSeccomp {
|
||||||
default_action: sec.DefaultAction.clone(),
|
default_action: sec.DefaultAction.clone(),
|
||||||
architectures: sec.Architectures.clone().into_vec(),
|
architectures: sec.Architectures.clone(),
|
||||||
flags: sec.Flags.clone().into_vec(),
|
flags: sec.Flags.clone(),
|
||||||
syscalls,
|
syscalls,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -456,8 +456,8 @@ fn linux_grpc_to_oci(l: &grpc::Linux) -> oci::Linux {
|
|||||||
devices,
|
devices,
|
||||||
seccomp,
|
seccomp,
|
||||||
rootfs_propagation: l.RootfsPropagation.clone(),
|
rootfs_propagation: l.RootfsPropagation.clone(),
|
||||||
masked_paths: l.MaskedPaths.clone().into_vec(),
|
masked_paths: l.MaskedPaths.clone(),
|
||||||
readonly_paths: l.ReadonlyPaths.clone().into_vec(),
|
readonly_paths: l.ReadonlyPaths.clone(),
|
||||||
mount_label: l.MountLabel.clone(),
|
mount_label: l.MountLabel.clone(),
|
||||||
intel_rdt,
|
intel_rdt,
|
||||||
}
|
}
|
||||||
|
@ -759,7 +759,7 @@ async fn vfio_pci_device_handler(
|
|||||||
device: &Device,
|
device: &Device,
|
||||||
sandbox: &Arc<Mutex<Sandbox>>,
|
sandbox: &Arc<Mutex<Sandbox>>,
|
||||||
) -> Result<SpecUpdate> {
|
) -> Result<SpecUpdate> {
|
||||||
let vfio_in_guest = device.field_type != DRIVER_VFIO_PCI_GK_TYPE;
|
let vfio_in_guest = device.type_ != DRIVER_VFIO_PCI_GK_TYPE;
|
||||||
let mut pci_fixups = Vec::<(pci::Address, pci::Address)>::new();
|
let mut pci_fixups = Vec::<(pci::Address, pci::Address)>::new();
|
||||||
let mut group = None;
|
let mut group = None;
|
||||||
|
|
||||||
@ -874,9 +874,9 @@ pub async fn add_devices(
|
|||||||
async fn add_device(device: &Device, sandbox: &Arc<Mutex<Sandbox>>) -> Result<SpecUpdate> {
|
async fn add_device(device: &Device, sandbox: &Arc<Mutex<Sandbox>>) -> Result<SpecUpdate> {
|
||||||
// log before validation to help with debugging gRPC protocol version differences.
|
// log before validation to help with debugging gRPC protocol version differences.
|
||||||
info!(sl!(), "device-id: {}, device-type: {}, device-vm-path: {}, device-container-path: {}, device-options: {:?}",
|
info!(sl!(), "device-id: {}, device-type: {}, device-vm-path: {}, device-container-path: {}, device-options: {:?}",
|
||||||
device.id, device.field_type, device.vm_path, device.container_path, device.options);
|
device.id, device.type_, device.vm_path, device.container_path, device.options);
|
||||||
|
|
||||||
if device.field_type.is_empty() {
|
if device.type_.is_empty() {
|
||||||
return Err(anyhow!("invalid type for device {:?}", device));
|
return Err(anyhow!("invalid type for device {:?}", device));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -888,7 +888,7 @@ async fn add_device(device: &Device, sandbox: &Arc<Mutex<Sandbox>>) -> Result<Sp
|
|||||||
return Err(anyhow!("invalid container path for device {:?}", device));
|
return Err(anyhow!("invalid container path for device {:?}", device));
|
||||||
}
|
}
|
||||||
|
|
||||||
match device.field_type.as_str() {
|
match device.type_.as_str() {
|
||||||
DRIVER_BLK_TYPE => virtio_blk_device_handler(device, sandbox).await,
|
DRIVER_BLK_TYPE => virtio_blk_device_handler(device, sandbox).await,
|
||||||
DRIVER_BLK_CCW_TYPE => virtio_blk_ccw_device_handler(device, sandbox).await,
|
DRIVER_BLK_CCW_TYPE => virtio_blk_ccw_device_handler(device, sandbox).await,
|
||||||
DRIVER_MMIO_BLK_TYPE => virtiommio_blk_device_handler(device, sandbox).await,
|
DRIVER_MMIO_BLK_TYPE => virtiommio_blk_device_handler(device, sandbox).await,
|
||||||
@ -898,7 +898,7 @@ async fn add_device(device: &Device, sandbox: &Arc<Mutex<Sandbox>>) -> Result<Sp
|
|||||||
vfio_pci_device_handler(device, sandbox).await
|
vfio_pci_device_handler(device, sandbox).await
|
||||||
}
|
}
|
||||||
DRIVER_VFIO_AP_TYPE => vfio_ap_device_handler(device, sandbox).await,
|
DRIVER_VFIO_AP_TYPE => vfio_ap_device_handler(device, sandbox).await,
|
||||||
_ => Err(anyhow!("Unknown device type {}", device.field_type)),
|
_ => Err(anyhow!("Unknown device type {}", device.type_)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ async fn ephemeral_storage_handler(
|
|||||||
if storage.options.len() > 0 {
|
if storage.options.len() > 0 {
|
||||||
// ephemeral_storage didn't support mount options except fsGroup.
|
// ephemeral_storage didn't support mount options except fsGroup.
|
||||||
let mut new_storage = storage.clone();
|
let mut new_storage = storage.clone();
|
||||||
new_storage.options = protobuf::RepeatedField::default();
|
new_storage.options = Default::default();
|
||||||
common_storage_handler(logger, &new_storage)?;
|
common_storage_handler(logger, &new_storage)?;
|
||||||
|
|
||||||
let opts_vec: Vec<String> = storage.options.to_vec();
|
let opts_vec: Vec<String> = storage.options.to_vec();
|
||||||
@ -654,7 +654,7 @@ pub fn set_ownership(logger: &Logger, storage: &Storage) -> Result<()> {
|
|||||||
if storage.fs_group.is_none() {
|
if storage.fs_group.is_none() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
let fs_group = storage.get_fs_group();
|
let fs_group = storage.fs_group();
|
||||||
|
|
||||||
let mut read_only = false;
|
let mut read_only = false;
|
||||||
let opts_vec: Vec<String> = storage.options.to_vec();
|
let opts_vec: Vec<String> = storage.options.to_vec();
|
||||||
@ -671,7 +671,7 @@ pub fn set_ownership(logger: &Logger, storage: &Storage) -> Result<()> {
|
|||||||
err
|
err
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
if fs_group.group_change_policy == FSGroupChangePolicy::OnRootMismatch
|
if fs_group.group_change_policy == FSGroupChangePolicy::OnRootMismatch.into()
|
||||||
&& metadata.gid() == fs_group.group_id
|
&& metadata.gid() == fs_group.group_id
|
||||||
{
|
{
|
||||||
let mut mask = if read_only { RO_MASK } else { RW_MASK };
|
let mut mask = if read_only { RO_MASK } else { RW_MASK };
|
||||||
|
@ -7,7 +7,6 @@ use anyhow::{anyhow, Context, Result};
|
|||||||
use futures::{future, StreamExt, TryStreamExt};
|
use futures::{future, StreamExt, TryStreamExt};
|
||||||
use ipnetwork::{IpNetwork, Ipv4Network, Ipv6Network};
|
use ipnetwork::{IpNetwork, Ipv4Network, Ipv6Network};
|
||||||
use nix::errno::Errno;
|
use nix::errno::Errno;
|
||||||
use protobuf::RepeatedField;
|
|
||||||
use protocols::types::{ARPNeighbor, IPAddress, IPFamily, Interface, Route};
|
use protocols::types::{ARPNeighbor, IPAddress, IPFamily, Interface, Route};
|
||||||
use rtnetlink::{new_connection, packet, IpVersion};
|
use rtnetlink::{new_connection, packet, IpVersion};
|
||||||
use std::convert::{TryFrom, TryInto};
|
use std::convert::{TryFrom, TryInto};
|
||||||
@ -83,8 +82,8 @@ impl Handle {
|
|||||||
|
|
||||||
// Add new ip addresses from request
|
// Add new ip addresses from request
|
||||||
for ip_address in &iface.IPAddresses {
|
for ip_address in &iface.IPAddresses {
|
||||||
let ip = IpAddr::from_str(ip_address.get_address())?;
|
let ip = IpAddr::from_str(ip_address.address())?;
|
||||||
let mask = ip_address.get_mask().parse::<u8>()?;
|
let mask = ip_address.mask().parse::<u8>()?;
|
||||||
|
|
||||||
self.add_addresses(link.index(), std::iter::once(IpNetwork::new(ip, mask)?))
|
self.add_addresses(link.index(), std::iter::once(IpNetwork::new(ip, mask)?))
|
||||||
.await?;
|
.await?;
|
||||||
@ -152,7 +151,7 @@ impl Handle {
|
|||||||
.map(|p| p.try_into())
|
.map(|p| p.try_into())
|
||||||
.collect::<Result<Vec<IPAddress>>>()?;
|
.collect::<Result<Vec<IPAddress>>>()?;
|
||||||
|
|
||||||
iface.IPAddresses = RepeatedField::from_vec(ips);
|
iface.IPAddresses = ips;
|
||||||
|
|
||||||
list.push(iface);
|
list.push(iface);
|
||||||
}
|
}
|
||||||
@ -334,7 +333,7 @@ impl Handle {
|
|||||||
|
|
||||||
// `rtnetlink` offers a separate request builders for different IP versions (IP v4 and v6).
|
// `rtnetlink` offers a separate request builders for different IP versions (IP v4 and v6).
|
||||||
// This if branch is a bit clumsy because it does almost the same.
|
// This if branch is a bit clumsy because it does almost the same.
|
||||||
if route.get_family() == IPFamily::v6 {
|
if route.family() == IPFamily::v6 {
|
||||||
let dest_addr = if !route.dest.is_empty() {
|
let dest_addr = if !route.dest.is_empty() {
|
||||||
Ipv6Network::from_str(&route.dest)?
|
Ipv6Network::from_str(&route.dest)?
|
||||||
} else {
|
} else {
|
||||||
@ -368,9 +367,9 @@ impl Handle {
|
|||||||
if Errno::from_i32(message.code.abs()) != Errno::EEXIST {
|
if Errno::from_i32(message.code.abs()) != Errno::EEXIST {
|
||||||
return Err(anyhow!(
|
return Err(anyhow!(
|
||||||
"Failed to add IP v6 route (src: {}, dst: {}, gtw: {},Err: {})",
|
"Failed to add IP v6 route (src: {}, dst: {}, gtw: {},Err: {})",
|
||||||
route.get_source(),
|
route.source(),
|
||||||
route.get_dest(),
|
route.dest(),
|
||||||
route.get_gateway(),
|
route.gateway(),
|
||||||
message
|
message
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -409,9 +408,9 @@ impl Handle {
|
|||||||
if Errno::from_i32(message.code.abs()) != Errno::EEXIST {
|
if Errno::from_i32(message.code.abs()) != Errno::EEXIST {
|
||||||
return Err(anyhow!(
|
return Err(anyhow!(
|
||||||
"Failed to add IP v4 route (src: {}, dst: {}, gtw: {},Err: {})",
|
"Failed to add IP v4 route (src: {}, dst: {}, gtw: {},Err: {})",
|
||||||
route.get_source(),
|
route.source(),
|
||||||
route.get_dest(),
|
route.dest(),
|
||||||
route.get_gateway(),
|
route.gateway(),
|
||||||
message
|
message
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -506,7 +505,7 @@ impl Handle {
|
|||||||
self.add_arp_neighbor(&neigh).await.map_err(|err| {
|
self.add_arp_neighbor(&neigh).await.map_err(|err| {
|
||||||
anyhow!(
|
anyhow!(
|
||||||
"Failed to add ARP neighbor {}: {:?}",
|
"Failed to add ARP neighbor {}: {:?}",
|
||||||
neigh.get_toIPAddress().get_address(),
|
neigh.toIPAddress().address(),
|
||||||
err
|
err
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
@ -725,7 +724,7 @@ impl TryFrom<Address> for IPAddress {
|
|||||||
let mask = format!("{}", value.0.header.prefix_len);
|
let mask = format!("{}", value.0.header.prefix_len);
|
||||||
|
|
||||||
Ok(IPAddress {
|
Ok(IPAddress {
|
||||||
family,
|
family: family.into(),
|
||||||
address,
|
address,
|
||||||
mask,
|
mask,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
@ -21,17 +21,20 @@ use ttrpc::{
|
|||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{anyhow, Context, Result};
|
||||||
use cgroups::freezer::FreezerState;
|
use cgroups::freezer::FreezerState;
|
||||||
use oci::{LinuxNamespace, Root, Spec};
|
use oci::{LinuxNamespace, Root, Spec};
|
||||||
use protobuf::{Message, RepeatedField, SingularPtrField};
|
use protobuf::{MessageDyn, MessageField};
|
||||||
use protocols::agent::{
|
use protocols::agent::{
|
||||||
AddSwapRequest, AgentDetails, CopyFileRequest, GetIPTablesRequest, GetIPTablesResponse,
|
AddSwapRequest, AgentDetails, CopyFileRequest, GetIPTablesRequest, GetIPTablesResponse,
|
||||||
GuestDetailsResponse, Interfaces, Metrics, OOMEvent, ReadStreamResponse, Routes,
|
GuestDetailsResponse, Interfaces, Metrics, OOMEvent, ReadStreamResponse, Routes,
|
||||||
SetIPTablesRequest, SetIPTablesResponse, StatsContainerResponse, VolumeStatsRequest,
|
SetIPTablesRequest, SetIPTablesResponse, StatsContainerResponse, VolumeStatsRequest,
|
||||||
WaitProcessResponse, WriteStreamResponse,
|
WaitProcessResponse, WriteStreamResponse,
|
||||||
};
|
};
|
||||||
use protocols::csi::{VolumeCondition, VolumeStatsResponse, VolumeUsage, VolumeUsage_Unit};
|
use protocols::csi::{
|
||||||
|
volume_usage::Unit as VolumeUsage_Unit, VolumeCondition, VolumeStatsResponse, VolumeUsage,
|
||||||
|
};
|
||||||
use protocols::empty::Empty;
|
use protocols::empty::Empty;
|
||||||
use protocols::health::{
|
use protocols::health::{
|
||||||
HealthCheckResponse, HealthCheckResponse_ServingStatus, VersionCheckResponse,
|
health_check_response::ServingStatus as HealthCheckResponse_ServingStatus, HealthCheckResponse,
|
||||||
|
VersionCheckResponse,
|
||||||
};
|
};
|
||||||
use protocols::types::Interface;
|
use protocols::types::Interface;
|
||||||
use protocols::{agent_ttrpc_async as agent_ttrpc, health_ttrpc_async as health_ttrpc};
|
use protocols::{agent_ttrpc_async as agent_ttrpc, health_ttrpc_async as health_ttrpc};
|
||||||
@ -124,11 +127,11 @@ macro_rules! is_allowed {
|
|||||||
if !AGENT_CONFIG
|
if !AGENT_CONFIG
|
||||||
.read()
|
.read()
|
||||||
.await
|
.await
|
||||||
.is_allowed_endpoint($req.descriptor().name())
|
.is_allowed_endpoint($req.descriptor_dyn().name())
|
||||||
{
|
{
|
||||||
return Err(ttrpc_error!(
|
return Err(ttrpc_error!(
|
||||||
ttrpc::Code::UNIMPLEMENTED,
|
ttrpc::Code::UNIMPLEMENTED,
|
||||||
format!("{} is blocked", $req.descriptor().name()),
|
format!("{} is blocked", $req.descriptor_dyn().name()),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -151,7 +154,7 @@ impl AgentService {
|
|||||||
kata_sys_util::validate::verify_id(&cid)?;
|
kata_sys_util::validate::verify_id(&cid)?;
|
||||||
|
|
||||||
let mut oci_spec = req.OCI.clone();
|
let mut oci_spec = req.OCI.clone();
|
||||||
let use_sandbox_pidns = req.get_sandbox_pidns();
|
let use_sandbox_pidns = req.sandbox_pidns();
|
||||||
|
|
||||||
let sandbox;
|
let sandbox;
|
||||||
let mut s;
|
let mut s;
|
||||||
@ -785,7 +788,7 @@ impl agent_ttrpc::AgentService for AgentService {
|
|||||||
) -> ttrpc::Result<protocols::empty::Empty> {
|
) -> ttrpc::Result<protocols::empty::Empty> {
|
||||||
trace_rpc_call!(ctx, "pause_container", req);
|
trace_rpc_call!(ctx, "pause_container", req);
|
||||||
is_allowed!(req);
|
is_allowed!(req);
|
||||||
let cid = req.get_container_id();
|
let cid = req.container_id();
|
||||||
let s = Arc::clone(&self.sandbox);
|
let s = Arc::clone(&self.sandbox);
|
||||||
let mut sandbox = s.lock().await;
|
let mut sandbox = s.lock().await;
|
||||||
|
|
||||||
@ -809,7 +812,7 @@ impl agent_ttrpc::AgentService for AgentService {
|
|||||||
) -> ttrpc::Result<protocols::empty::Empty> {
|
) -> ttrpc::Result<protocols::empty::Empty> {
|
||||||
trace_rpc_call!(ctx, "resume_container", req);
|
trace_rpc_call!(ctx, "resume_container", req);
|
||||||
is_allowed!(req);
|
is_allowed!(req);
|
||||||
let cid = req.get_container_id();
|
let cid = req.container_id();
|
||||||
let s = Arc::clone(&self.sandbox);
|
let s = Arc::clone(&self.sandbox);
|
||||||
let mut sandbox = s.lock().await;
|
let mut sandbox = s.lock().await;
|
||||||
|
|
||||||
@ -964,16 +967,12 @@ impl agent_ttrpc::AgentService for AgentService {
|
|||||||
trace_rpc_call!(ctx, "update_routes", req);
|
trace_rpc_call!(ctx, "update_routes", req);
|
||||||
is_allowed!(req);
|
is_allowed!(req);
|
||||||
|
|
||||||
let new_routes = req
|
let new_routes = req.routes.into_option().map(|r| r.Routes).ok_or_else(|| {
|
||||||
.routes
|
ttrpc_error!(
|
||||||
.into_option()
|
ttrpc::Code::INVALID_ARGUMENT,
|
||||||
.map(|r| r.Routes.into_vec())
|
"empty update routes request".to_string(),
|
||||||
.ok_or_else(|| {
|
)
|
||||||
ttrpc_error!(
|
})?;
|
||||||
ttrpc::Code::INVALID_ARGUMENT,
|
|
||||||
"empty update routes request".to_string(),
|
|
||||||
)
|
|
||||||
})?;
|
|
||||||
|
|
||||||
let mut sandbox = self.sandbox.lock().await;
|
let mut sandbox = self.sandbox.lock().await;
|
||||||
|
|
||||||
@ -992,7 +991,7 @@ impl agent_ttrpc::AgentService for AgentService {
|
|||||||
})?;
|
})?;
|
||||||
|
|
||||||
Ok(protocols::agent::Routes {
|
Ok(protocols::agent::Routes {
|
||||||
Routes: RepeatedField::from_vec(list),
|
Routes: list,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -1191,7 +1190,7 @@ impl agent_ttrpc::AgentService for AgentService {
|
|||||||
})?;
|
})?;
|
||||||
|
|
||||||
Ok(protocols::agent::Interfaces {
|
Ok(protocols::agent::Interfaces {
|
||||||
Interfaces: RepeatedField::from_vec(list),
|
Interfaces: list,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -1214,7 +1213,7 @@ impl agent_ttrpc::AgentService for AgentService {
|
|||||||
.map_err(|e| ttrpc_error!(ttrpc::Code::INTERNAL, format!("list routes: {:?}", e)))?;
|
.map_err(|e| ttrpc_error!(ttrpc::Code::INTERNAL, format!("list routes: {:?}", e)))?;
|
||||||
|
|
||||||
Ok(protocols::agent::Routes {
|
Ok(protocols::agent::Routes {
|
||||||
Routes: RepeatedField::from_vec(list),
|
Routes: list,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -1330,7 +1329,7 @@ impl agent_ttrpc::AgentService for AgentService {
|
|||||||
let neighs = req
|
let neighs = req
|
||||||
.neighbors
|
.neighbors
|
||||||
.into_option()
|
.into_option()
|
||||||
.map(|n| n.ARPNeighbors.into_vec())
|
.map(|n| n.ARPNeighbors)
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| {
|
||||||
ttrpc_error!(
|
ttrpc_error!(
|
||||||
ttrpc::Code::INVALID_ARGUMENT,
|
ttrpc::Code::INVALID_ARGUMENT,
|
||||||
@ -1414,7 +1413,7 @@ impl agent_ttrpc::AgentService for AgentService {
|
|||||||
|
|
||||||
// to get agent details
|
// to get agent details
|
||||||
let detail = get_agent_details();
|
let detail = get_agent_details();
|
||||||
resp.agent_details = SingularPtrField::some(detail);
|
resp.agent_details = MessageField::some(detail);
|
||||||
|
|
||||||
Ok(resp)
|
Ok(resp)
|
||||||
}
|
}
|
||||||
@ -1539,8 +1538,8 @@ impl agent_ttrpc::AgentService for AgentService {
|
|||||||
.map(|u| usage_vec.push(u))
|
.map(|u| usage_vec.push(u))
|
||||||
.map_err(|e| ttrpc_error!(ttrpc::Code::INTERNAL, e))?;
|
.map_err(|e| ttrpc_error!(ttrpc::Code::INTERNAL, e))?;
|
||||||
|
|
||||||
resp.usage = RepeatedField::from_vec(usage_vec);
|
resp.usage = usage_vec;
|
||||||
resp.volume_condition = SingularPtrField::some(condition);
|
resp.volume_condition = MessageField::some(condition);
|
||||||
Ok(resp)
|
Ok(resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1644,7 +1643,7 @@ fn get_volume_capacity_stats(path: &str) -> Result<VolumeUsage> {
|
|||||||
usage.total = stat.blocks() * block_size;
|
usage.total = stat.blocks() * block_size;
|
||||||
usage.available = stat.blocks_free() * block_size;
|
usage.available = stat.blocks_free() * block_size;
|
||||||
usage.used = usage.total - usage.available;
|
usage.used = usage.total - usage.available;
|
||||||
usage.unit = VolumeUsage_Unit::BYTES;
|
usage.unit = VolumeUsage_Unit::BYTES.into();
|
||||||
|
|
||||||
Ok(usage)
|
Ok(usage)
|
||||||
}
|
}
|
||||||
@ -1656,7 +1655,7 @@ fn get_volume_inode_stats(path: &str) -> Result<VolumeUsage> {
|
|||||||
usage.total = stat.files();
|
usage.total = stat.files();
|
||||||
usage.available = stat.files_free();
|
usage.available = stat.files_free();
|
||||||
usage.used = usage.total - usage.available;
|
usage.used = usage.total - usage.available;
|
||||||
usage.unit = VolumeUsage_Unit::INODES;
|
usage.unit = VolumeUsage_Unit::INODES.into();
|
||||||
|
|
||||||
Ok(usage)
|
Ok(usage)
|
||||||
}
|
}
|
||||||
@ -1676,14 +1675,12 @@ fn get_agent_details() -> AgentDetails {
|
|||||||
detail.set_supports_seccomp(have_seccomp());
|
detail.set_supports_seccomp(have_seccomp());
|
||||||
detail.init_daemon = unistd::getpid() == Pid::from_raw(1);
|
detail.init_daemon = unistd::getpid() == Pid::from_raw(1);
|
||||||
|
|
||||||
detail.device_handlers = RepeatedField::new();
|
detail.device_handlers = Vec::new();
|
||||||
detail.storage_handlers = RepeatedField::from_vec(
|
detail.storage_handlers = STORAGE_HANDLER_LIST
|
||||||
STORAGE_HANDLER_LIST
|
.to_vec()
|
||||||
.to_vec()
|
.iter()
|
||||||
.iter()
|
.map(|x| x.to_string())
|
||||||
.map(|x| x.to_string())
|
.collect();
|
||||||
.collect(),
|
|
||||||
);
|
|
||||||
|
|
||||||
detail
|
detail
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user