diff --git a/src/agent/src/mount.rs b/src/agent/src/mount.rs index 20fd0494c..d2ab2b132 100644 --- a/src/agent/src/mount.rs +++ b/src/agent/src/mount.rs @@ -405,14 +405,18 @@ async fn bind_watcher_storage_handler( logger: &Logger, storage: &Storage, sandbox: Arc>, + cid: Option, ) -> Result<()> { let mut locked = sandbox.lock().await; - let container_id = locked.id.clone(); - locked - .bind_watcher - .add_container(container_id, iter::once(storage.clone()), logger) - .await + if let Some(cid) = cid { + locked + .bind_watcher + .add_container(cid, iter::once(storage.clone()), logger) + .await + } else { + Ok(()) + } } // mount_storage performs the mount described by the storage structure. @@ -521,6 +525,7 @@ pub async fn add_storages( logger: Logger, storages: Vec, sandbox: Arc>, + cid: Option, ) -> Result> { let mut mount_list = Vec::new(); @@ -551,7 +556,8 @@ pub async fn add_storages( } DRIVER_NVDIMM_TYPE => nvdimm_storage_handler(&logger, &storage, sandbox.clone()).await, DRIVER_WATCHABLE_BIND_TYPE => { - bind_watcher_storage_handler(&logger, &storage, sandbox.clone()).await?; + bind_watcher_storage_handler(&logger, &storage, sandbox.clone(), cid.clone()) + .await?; // Don't register watch mounts, they're handled separately by the watcher. Ok(String::new()) } diff --git a/src/agent/src/rpc.rs b/src/agent/src/rpc.rs index 095936470..052c4716c 100644 --- a/src/agent/src/rpc.rs +++ b/src/agent/src/rpc.rs @@ -155,6 +155,10 @@ impl AgentService { }; info!(sl!(), "receive createcontainer, spec: {:?}", &oci); + info!( + sl!(), + "receive createcontainer, storages: {:?}", &req.storages + ); // Some devices need some extra processing (the ones invoked with // --device for instance), and that's what this call is doing. It @@ -170,7 +174,13 @@ impl AgentService { // After all those storages have been processed, no matter the order // here, the agent will rely on rustjail (using the oci.Mounts // list) to bind mount all of them inside the container. - let m = add_storages(sl!(), req.storages.to_vec(), self.sandbox.clone()).await?; + let m = add_storages( + sl!(), + req.storages.to_vec(), + self.sandbox.clone(), + Some(req.container_id.clone()), + ) + .await?; { sandbox = self.sandbox.clone(); s = sandbox.lock().await; @@ -580,6 +590,7 @@ impl protocols::agent_ttrpc::AgentService for AgentService { ) -> ttrpc::Result { trace_rpc_call!(ctx, "remove_container", req); is_allowed!(req); + match self.do_remove_container(req).await { Err(e) => Err(ttrpc_error(ttrpc::Code::INTERNAL, e.to_string())), Ok(_) => Ok(Empty::new()), @@ -993,7 +1004,7 @@ impl protocols::agent_ttrpc::AgentService for AgentService { .map_err(|e| ttrpc_error(ttrpc::Code::INTERNAL, e.to_string()))?; } - match add_storages(sl!(), req.storages.to_vec(), self.sandbox.clone()).await { + match add_storages(sl!(), req.storages.to_vec(), self.sandbox.clone(), None).await { Ok(m) => { let sandbox = self.sandbox.clone(); let mut s = sandbox.lock().await;