mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-29 12:14:48 +00:00
agent: make add_storage() take &[Storage] instead of Vec<Storage>
Simplify add_storage() by taking &[Storage] instead of Vec<Storage>. Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
This commit is contained in:
parent
37f34781d1
commit
5333618d70
@ -861,17 +861,16 @@ fn parse_mount_flags_and_options(options_vec: Vec<&str>) -> (MsFlags, String) {
|
||||
#[instrument]
|
||||
pub async fn add_storages(
|
||||
logger: Logger,
|
||||
storages: Vec<Storage>,
|
||||
storages: &[Storage],
|
||||
sandbox: &Arc<Mutex<Sandbox>>,
|
||||
cid: Option<String>,
|
||||
) -> Result<Vec<String>> {
|
||||
let mut mount_list = Vec::new();
|
||||
|
||||
for storage in storages {
|
||||
let handler_name = storage.driver.clone();
|
||||
let logger = logger.new(o!(
|
||||
"subsystem" => "storage",
|
||||
"storage-type" => handler_name.to_owned()));
|
||||
let handler_name = &storage.driver;
|
||||
let logger =
|
||||
logger.new(o!( "subsystem" => "storage", "storage-type" => handler_name.to_string()));
|
||||
|
||||
{
|
||||
let mut sb = sandbox.lock().await;
|
||||
@ -916,9 +915,9 @@ pub async fn add_storages(
|
||||
"add_storages failed, storage: {:?}, error: {:?} ", storage, e
|
||||
);
|
||||
let mut sb = sandbox.lock().await;
|
||||
sb.unset_sandbox_storage(&storage.mount_point)
|
||||
.map_err(|e| warn!(logger, "fail to unset sandbox storage {:?}", e))
|
||||
.ok();
|
||||
if let Err(e) = sb.unset_sandbox_storage(&storage.mount_point) {
|
||||
warn!(logger, "fail to unset sandbox storage {:?}", e);
|
||||
}
|
||||
return Err(e);
|
||||
}
|
||||
Ok(m) => m,
|
||||
|
@ -180,7 +180,7 @@ impl AgentService {
|
||||
// list) to bind mount all of them inside the container.
|
||||
let m = add_storages(
|
||||
sl(),
|
||||
req.storages,
|
||||
&req.storages,
|
||||
&self.sandbox,
|
||||
Some(req.container_id.clone()),
|
||||
)
|
||||
@ -1217,7 +1217,7 @@ impl agent_ttrpc::AgentService for AgentService {
|
||||
.map_err(|e| ttrpc_error(ttrpc::Code::INTERNAL, e))?;
|
||||
}
|
||||
|
||||
match add_storages(sl(), req.storages.to_vec(), &self.sandbox, None).await {
|
||||
match add_storages(sl(), &req.storages, &self.sandbox, None).await {
|
||||
Ok(m) => {
|
||||
self.sandbox.lock().await.mounts = m;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user