mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-30 17:22:33 +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]
|
#[instrument]
|
||||||
pub async fn add_storages(
|
pub async fn add_storages(
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
storages: Vec<Storage>,
|
storages: &[Storage],
|
||||||
sandbox: &Arc<Mutex<Sandbox>>,
|
sandbox: &Arc<Mutex<Sandbox>>,
|
||||||
cid: Option<String>,
|
cid: Option<String>,
|
||||||
) -> Result<Vec<String>> {
|
) -> Result<Vec<String>> {
|
||||||
let mut mount_list = Vec::new();
|
let mut mount_list = Vec::new();
|
||||||
|
|
||||||
for storage in storages {
|
for storage in storages {
|
||||||
let handler_name = storage.driver.clone();
|
let handler_name = &storage.driver;
|
||||||
let logger = logger.new(o!(
|
let logger =
|
||||||
"subsystem" => "storage",
|
logger.new(o!( "subsystem" => "storage", "storage-type" => handler_name.to_string()));
|
||||||
"storage-type" => handler_name.to_owned()));
|
|
||||||
|
|
||||||
{
|
{
|
||||||
let mut sb = sandbox.lock().await;
|
let mut sb = sandbox.lock().await;
|
||||||
@ -916,9 +915,9 @@ pub async fn add_storages(
|
|||||||
"add_storages failed, storage: {:?}, error: {:?} ", storage, e
|
"add_storages failed, storage: {:?}, error: {:?} ", storage, e
|
||||||
);
|
);
|
||||||
let mut sb = sandbox.lock().await;
|
let mut sb = sandbox.lock().await;
|
||||||
sb.unset_sandbox_storage(&storage.mount_point)
|
if let Err(e) = sb.unset_sandbox_storage(&storage.mount_point) {
|
||||||
.map_err(|e| warn!(logger, "fail to unset sandbox storage {:?}", e))
|
warn!(logger, "fail to unset sandbox storage {:?}", e);
|
||||||
.ok();
|
}
|
||||||
return Err(e);
|
return Err(e);
|
||||||
}
|
}
|
||||||
Ok(m) => m,
|
Ok(m) => m,
|
||||||
|
@ -180,7 +180,7 @@ impl AgentService {
|
|||||||
// list) to bind mount all of them inside the container.
|
// list) to bind mount all of them inside the container.
|
||||||
let m = add_storages(
|
let m = add_storages(
|
||||||
sl(),
|
sl(),
|
||||||
req.storages,
|
&req.storages,
|
||||||
&self.sandbox,
|
&self.sandbox,
|
||||||
Some(req.container_id.clone()),
|
Some(req.container_id.clone()),
|
||||||
)
|
)
|
||||||
@ -1217,7 +1217,7 @@ impl agent_ttrpc::AgentService for AgentService {
|
|||||||
.map_err(|e| ttrpc_error(ttrpc::Code::INTERNAL, e))?;
|
.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) => {
|
Ok(m) => {
|
||||||
self.sandbox.lock().await.mounts = m;
|
self.sandbox.lock().await.mounts = m;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user