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