mirror of
https://github.com/michael-yuji/xc.git
synced 2025-12-11 17:29:43 +01:00
readability fix
This commit is contained in:
@@ -82,6 +82,7 @@ pub struct ServerContext {
|
||||
|
||||
pub(crate) resources: Arc<RwLock<Resources>>,
|
||||
|
||||
// a map of instantiate request that passed checks
|
||||
pub(crate) ins_queue: HashMap<String, CheckedInstantiateRequest>,
|
||||
}
|
||||
|
||||
@@ -141,6 +142,7 @@ impl ServerContext {
|
||||
.clone()
|
||||
}
|
||||
|
||||
// Establish a external RPC channel
|
||||
pub(crate) fn create_channel(
|
||||
this: Arc<RwLock<ServerContext>>,
|
||||
path: impl AsRef<std::path::Path>,
|
||||
@@ -207,6 +209,7 @@ impl ServerContext {
|
||||
Some(result)
|
||||
}
|
||||
|
||||
/// Find a terminated container given an ID
|
||||
pub async fn find_corpse(&self, id: &str) -> Option<ContainerManifest> {
|
||||
for (cid, container) in self.terminated_sites.iter().rev() {
|
||||
if cid == id {
|
||||
@@ -221,7 +224,7 @@ impl ServerContext {
|
||||
self.sites.get(id).cloned()
|
||||
}
|
||||
|
||||
pub(super) async fn update_hosts(&mut self, network: &str) {
|
||||
pub(super) async fn update_host_file_for_containers_using_network(&mut self, network: &str) {
|
||||
let mut hosts = Vec::new();
|
||||
if let Some(jails) = self.ng2jails.get(network) {
|
||||
for jail in jails.iter() {
|
||||
@@ -395,7 +398,7 @@ impl ServerContext {
|
||||
}
|
||||
|
||||
pub(crate) async fn destroy_context(&mut self, id: &str) -> Result<(), anyhow::Error> {
|
||||
info!("destroy conetxt: {id}");
|
||||
info!(id, "destroy conetxt");
|
||||
if let Some(site) = self.sites.remove(&id.to_string()) {
|
||||
if let Err(err) = site.write().await.unwind() {
|
||||
error!("error on unwind: {err:#?}");
|
||||
@@ -616,7 +619,7 @@ impl ServerContext {
|
||||
.insert(netgroup.to_string(), vec![id.to_string()]);
|
||||
}
|
||||
this.jail2ngs.get_mut(id).unwrap().push(netgroup.clone());
|
||||
this.update_hosts(&netgroup).await;
|
||||
this.update_host_file_for_containers_using_network(&netgroup).await;
|
||||
}
|
||||
|
||||
(arc_site, notify)
|
||||
|
||||
@@ -398,10 +398,13 @@ async fn continue_instantiate(
|
||||
return enoent("no such instantiate request");
|
||||
};
|
||||
let credential = Credential::from_conn_ctx(local_context);
|
||||
ServerContext::continue_instantiate(context, &request.id, applied, credential)
|
||||
.await
|
||||
.expect("todo");
|
||||
Ok(ContinueInstantiateResponse { id: request.id })
|
||||
match ServerContext::continue_instantiate(context, &request.id, applied, credential).await {
|
||||
Ok(_) => Ok(ContinueInstantiateResponse { id: request.id }),
|
||||
Err(error) => {
|
||||
error!(error=error.to_string(), "failed to instantiate container");
|
||||
ipc_err(EIO, "failed to instantiate container: {error:?}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
@@ -1148,7 +1151,7 @@ async fn commit_netgroup(
|
||||
context
|
||||
.write()
|
||||
.await
|
||||
.update_hosts(&request.netgroup_name)
|
||||
.update_host_file_for_containers_using_network(&request.netgroup_name)
|
||||
.await;
|
||||
Ok(())
|
||||
}
|
||||
@@ -1192,7 +1195,7 @@ async fn add_container_to_netgroup(
|
||||
};
|
||||
|
||||
if request.commit_immediately {
|
||||
context.update_hosts(&ng_name).await;
|
||||
context.update_host_file_for_containers_using_network(&ng_name).await;
|
||||
}
|
||||
Ok(())
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user