agent: fix non_snake_case lint and remove ![allow(non_snake_case)]

Fixes: #1359

Signed-off-by: Tim Zhang <tim@hyper.sh>
This commit is contained in:
Tim Zhang 2021-02-04 20:43:50 +08:00
parent 38b5a43267
commit 05da23acb7
5 changed files with 12 additions and 13 deletions

View File

@ -105,7 +105,7 @@ impl agentConfig {
HOTPLUG_TIMOUT_OPTION,
self.hotplug_timeout,
get_hotplug_timeout,
|hotplugTimeout: time::Duration| hotplugTimeout.as_secs() > 0
|hotplug_timeout: time::Duration| hotplug_timeout.as_secs() > 0
);
// vsock port should be positive values

View File

@ -7,7 +7,6 @@
#![allow(unused_parens)]
#![allow(unused_unsafe)]
#![allow(dead_code)]
#![allow(non_snake_case)]
#[macro_use]
extern crate lazy_static;
extern crate oci;
@ -161,7 +160,7 @@ fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
// support vsock log
let (rfd, wfd) = unistd::pipe2(OFlag::O_CLOEXEC)?;
let agentConfig = AGENT_CONFIG.clone();
let agent_config = AGENT_CONFIG.clone();
let init_mode = unistd::getpid() == Pid::from_raw(1);
if init_mode {
@ -182,7 +181,7 @@ fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
e
})?;
let mut config = agentConfig.write().await;
let mut config = agent_config.write().await;
config.parse_cmdline(KERNEL_CMDLINE_FILE)?;
init_agent_as_init(&logger, config.unified_cgroup_hierarchy)?;
@ -190,10 +189,10 @@ fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
// once parsed cmdline and set the config, release the write lock
// as soon as possible in case other thread would get read lock on
// it.
let mut config = agentConfig.write().await;
let mut config = agent_config.write().await;
config.parse_cmdline(KERNEL_CMDLINE_FILE)?;
}
let config = agentConfig.read().await;
let config = agent_config.read().await;
let log_vport = config.log_vport as u32;
let log_handle = tokio::spawn(async move {

View File

@ -187,9 +187,9 @@ fn update_guest_metrics() {
info!(sl!(), "failed to get guest KernelStats: {:?}", err);
}
Ok(kernel_stats) => {
set_gauge_vec_CPU_time(&GUEST_CPU_TIME, "total", &kernel_stats.total);
set_gauge_vec_cpu_time(&GUEST_CPU_TIME, "total", &kernel_stats.total);
for (i, cpu_time) in kernel_stats.cpu_time.iter().enumerate() {
set_gauge_vec_CPU_time(&GUEST_CPU_TIME, format!("{}", i).as_str(), &cpu_time);
set_gauge_vec_cpu_time(&GUEST_CPU_TIME, format!("{}", i).as_str(), &cpu_time);
}
}
}
@ -332,7 +332,7 @@ fn set_gauge_vec_meminfo(gv: &prometheus::GaugeVec, meminfo: &procfs::Meminfo) {
.set(meminfo.k_reclaimable.unwrap_or(0) as f64);
}
fn set_gauge_vec_CPU_time(gv: &prometheus::GaugeVec, cpu: &str, cpu_time: &procfs::CpuTime) {
fn set_gauge_vec_cpu_time(gv: &prometheus::GaugeVec, cpu: &str, cpu_time: &procfs::CpuTime) {
gv.with_label_values(&[cpu, "user"])
.set(cpu_time.user as f64);
gv.with_label_values(&[cpu, "nice"])

View File

@ -139,10 +139,10 @@ mod tests {
assert_eq!(true, content.is_ok());
let content = content.unwrap();
let expected_DNS: Vec<&str> = content.split('\n').collect();
let expected_dns: Vec<&str> = content.split('\n').collect();
// assert the data are the same as /run/kata-containers/sandbox/resolv.conf
assert_eq!(dns, expected_DNS);
assert_eq!(dns, expected_dns);
// umount /etc/resolv.conf
let _ = mount::umount(dst_filename);

View File

@ -665,8 +665,8 @@ impl protocols::agent_ttrpc::AgentService for agentService {
let resp = Empty::new();
if res.is_some() {
let ociRes = rustjail::resources_grpc_to_oci(&res.unwrap());
match ctr.set(ociRes) {
let oci_res = rustjail::resources_grpc_to_oci(&res.unwrap());
match ctr.set(oci_res) {
Err(e) => {
return Err(ttrpc_error(ttrpc::Code::INTERNAL, e.to_string()));
}