mirror of
https://github.com/faas-rs/faasd-in-rust.git
synced 2025-06-18 12:06:35 +00:00
fix(log):replace all println! with log
This commit is contained in:
@ -146,11 +146,11 @@ impl Service {
|
||||
};
|
||||
let mut cc = self.client.containers();
|
||||
|
||||
let responce = cc
|
||||
let response = cc
|
||||
.list(with_namespace!(request, namespace))
|
||||
.await?
|
||||
.into_inner();
|
||||
let container = responce
|
||||
let container = response
|
||||
.containers
|
||||
.iter()
|
||||
.find(|container| container.id == cid);
|
||||
@ -161,15 +161,15 @@ impl Service {
|
||||
let request = ListTasksRequest {
|
||||
filter: format!("container=={}", cid),
|
||||
};
|
||||
let responce = tc
|
||||
let response = tc
|
||||
.list(with_namespace!(request, namespace))
|
||||
.await?
|
||||
.into_inner();
|
||||
println!("Tasks: {:?}", responce.tasks);
|
||||
log::info!("Tasks: {:?}", response.tasks);
|
||||
drop(tc);
|
||||
|
||||
if let Some(task) = responce.tasks.iter().find(|task| task.id == container.id) {
|
||||
println!("Task found: {}, Status: {}", task.id, task.status);
|
||||
if let Some(task) = response.tasks.iter().find(|task| task.id == container.id) {
|
||||
log::info!("Task found: {}, Status: {}", task.id, task.status);
|
||||
// TASK_UNKNOWN (0) — 未知状态
|
||||
// TASK_CREATED (1) — 任务已创建
|
||||
// TASK_RUNNING (2) — 任务正在运行
|
||||
@ -192,7 +192,7 @@ impl Service {
|
||||
//todo 这里删除cni?
|
||||
self.remove_netns_ip(cid).await;
|
||||
|
||||
println!("Container: {:?} deleted", cc);
|
||||
log::info!("Container: {:?} deleted", cc);
|
||||
} else {
|
||||
todo!("Container not found");
|
||||
}
|
||||
@ -227,17 +227,17 @@ impl Service {
|
||||
.into_inner()
|
||||
.mounts;
|
||||
|
||||
println!("mounts ok");
|
||||
log::info!("mounts ok");
|
||||
drop(sc);
|
||||
println!("drop sc ok");
|
||||
log::info!("drop sc ok");
|
||||
let _ = cni::init_net_work();
|
||||
println!("init_net_work ok");
|
||||
log::info!("init_net_work ok");
|
||||
let (ip, path) = cni::create_cni_network(cid.to_string(), ns.to_string())?;
|
||||
let ports = ImageManager::get_runtime_config(img_name).unwrap().ports;
|
||||
let network_config = NetworkConfig::new(path, ip, ports);
|
||||
println!("create_cni_network ok");
|
||||
log::info!("create_cni_network ok");
|
||||
self.save_network_config(cid, network_config.clone()).await;
|
||||
println!("save_netns_ip ok, netconfig: {:?}", network_config);
|
||||
log::info!("save_netns_ip ok, netconfig: {:?}", network_config);
|
||||
let mut tc = self.client.tasks();
|
||||
let req = CreateTaskRequest {
|
||||
container_id: cid.to_string(),
|
||||
@ -255,7 +255,7 @@ impl Service {
|
||||
..Default::default()
|
||||
};
|
||||
let _resp = self.client.tasks().start(with_namespace!(req, ns)).await?;
|
||||
println!("Task: {:?} started", cid);
|
||||
log::info!("Task: {:?} started", cid);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -299,7 +299,7 @@ impl Service {
|
||||
Ok::<(), Err>(())
|
||||
})
|
||||
.await;
|
||||
println!(" after wait");
|
||||
log::info!("after wait");
|
||||
|
||||
let kill_request = KillRequest {
|
||||
container_id: cid.to_string(),
|
||||
@ -324,17 +324,17 @@ impl Service {
|
||||
// println!("Task: {:?} deleted", cid);
|
||||
match c.delete(with_namespace!(req, namespace)).await {
|
||||
Ok(_) => {
|
||||
println!("Task: {:?} deleted", cid);
|
||||
log::info!("Task: {:?} deleted", cid);
|
||||
Ok(())
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("Failed to delete task: {}", e);
|
||||
log::error!("Failed to delete task: {}", e);
|
||||
Err(e.into())
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(Err(e)) => {
|
||||
eprintln!("Wait task failed: {}", e);
|
||||
log::error!("Wait task failed: {}", e);
|
||||
Err(e)
|
||||
}
|
||||
Err(_) => {
|
||||
@ -346,11 +346,11 @@ impl Service {
|
||||
};
|
||||
match c.kill(with_namespace!(kill_request, namespace)).await {
|
||||
Ok(_) => {
|
||||
println!("Task: {:?} force killed", cid);
|
||||
log::info!("Task: {:?} force killed", cid);
|
||||
Ok(())
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("Failed to force kill task: {}", e);
|
||||
log::error!("Failed to force kill task: {}", e);
|
||||
Err(e.into())
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user