diff --git a/src/agent/src/mount.rs b/src/agent/src/mount.rs index 3d55f874f0..0ea4d34cbf 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. @@ -518,6 +522,7 @@ pub async fn add_storages( logger: Logger, storages: Vec, sandbox: Arc>, + cid: Option, ) -> Result> { let mut mount_list = Vec::new(); @@ -548,7 +553,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 424da5df09..e6543cdb95 100644 --- a/src/agent/src/rpc.rs +++ b/src/agent/src/rpc.rs @@ -148,6 +148,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 @@ -163,7 +167,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; @@ -573,6 +583,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()), @@ -1002,7 +1013,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;