Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions brane-api/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use brane_cfg::info::Info as _;
use brane_cfg::infra::InfraFile;
use brane_cfg::node::NodeConfig;
use brane_prx::spec::NewPathRequestTlsOptions;
use error_trace::{ErrorTrace as _, trace};
use log::{debug, error};
use reqwest::StatusCode;
use specifications::data::{AssetInfo, DataInfo};
Expand Down Expand Up @@ -60,7 +61,7 @@ pub async fn list(context: Context) -> Result<impl Reply, Rejection> {
let node_config: NodeConfig = match NodeConfig::from_path(&context.node_config_path) {
Ok(config) => config,
Err(source) => {
error!("Failed to load NodeConfig file: {}", source);
error!("{}", trace!(("Failed to load NodeConfig file"), source));
return Err(warp::reject::custom(Error::SecretError));
},
};
Expand All @@ -73,7 +74,7 @@ pub async fn list(context: Context) -> Result<impl Reply, Rejection> {
let infra: InfraFile = match InfraFile::from_path(&node_config.node.central().paths.infra) {
Ok(infra) => infra,
Err(source) => {
error!("{}", Error::InfrastructureOpenError { path: node_config.node.central().paths.infra.clone(), source });
error!("{}", Error::InfrastructureOpenError { path: node_config.node.central().paths.infra.clone(), source }.trace());
return Err(warp::reject::custom(Error::SecretError));
},
};
Expand All @@ -88,12 +89,12 @@ pub async fn list(context: Context) -> Result<impl Reply, Rejection> {
Ok(res) => match res {
Ok(res) => res,
Err(source) => {
error!("{} (skipping domain)", Error::RequestError { address, source });
error!("{} (skipping domain)", Error::RequestError { address, source }.trace());
continue;
},
},
Err(source) => {
error!("{} (skipping domain)", Error::ProxyError { source });
error!("{} (skipping domain)", Error::ProxyError { source }.trace());
continue;
},
};
Expand All @@ -106,15 +107,15 @@ pub async fn list(context: Context) -> Result<impl Reply, Rejection> {
let body: String = match res.text().await {
Ok(body) => body,
Err(source) => {
error!("{} (skipping domain)", Error::ResponseBodyError { address, source });
error!("{} (skipping domain)", Error::ResponseBodyError { address, source }.trace());
continue;
},
};
let local_sets: HashMap<String, AssetInfo> = match serde_json::from_str(&body) {
Ok(body) => body,
Err(source) => {
debug!("Received body: \"\"\"{}\"\"\"", body);
error!("{} (skipping domain)", Error::ResponseParseError { address, source });
error!("{} (skipping domain)", Error::ResponseParseError { address, source }.trace());
continue;
},
};
Expand All @@ -134,7 +135,7 @@ pub async fn list(context: Context) -> Result<impl Reply, Rejection> {
let body: String = match serde_json::to_string(&datasets) {
Ok(body) => body,
Err(source) => {
error!("{}", Error::SerializeError { what: "list of all datasets", source });
error!("{}", Error::SerializeError { what: "list of all datasets", source }.trace());
fail!();
},
};
Expand Down Expand Up @@ -168,7 +169,7 @@ pub async fn get(name: String, context: Context) -> Result<impl Reply, Rejection
let node_config: NodeConfig = match NodeConfig::from_path(&context.node_config_path) {
Ok(config) => config,
Err(err) => {
error!("Failed to load NodeConfig file: {}", err);
error!("Failed to load NodeConfig file: {}", err.trace());
return Err(warp::reject::custom(Error::SecretError));
},
};
Expand All @@ -181,7 +182,7 @@ pub async fn get(name: String, context: Context) -> Result<impl Reply, Rejection
let infra: InfraFile = match InfraFile::from_path(&node_config.node.central().paths.infra) {
Ok(infra) => infra,
Err(source) => {
error!("{}", Error::InfrastructureOpenError { path: node_config.node.central().paths.infra.clone(), source });
error!("{}", Error::InfrastructureOpenError { path: node_config.node.central().paths.infra.clone(), source }.trace());
return Err(warp::reject::custom(Error::SecretError));
},
};
Expand All @@ -196,12 +197,12 @@ pub async fn get(name: String, context: Context) -> Result<impl Reply, Rejection
Ok(res) => match res {
Ok(res) => res,
Err(source) => {
error!("{} (skipping domain)", Error::RequestError { address, source });
error!("{} (skipping domain)", Error::RequestError { address, source }.trace());
continue;
},
},
Err(source) => {
error!("{} (skipping domain)", Error::ProxyError { source });
error!("{} (skipping domain)", Error::ProxyError { source }.trace());
continue;
},
};
Expand All @@ -214,15 +215,15 @@ pub async fn get(name: String, context: Context) -> Result<impl Reply, Rejection
let body: String = match res.text().await {
Ok(body) => body,
Err(source) => {
error!("{} (skipping domain datasets)", Error::ResponseBodyError { address, source });
error!("{} (skipping domain datasets)", Error::ResponseBodyError { address, source }.trace());
continue;
},
};
let local_set: AssetInfo = match serde_json::from_str(&body) {
Ok(body) => body,
Err(source) => {
debug!("Received body: \"\"\"{}\"\"\"", body);
error!("{} (skipping domain datasets)", Error::ResponseParseError { address, source });
error!("{} (skipping domain datasets)", Error::ResponseParseError { address, source }.trace());
continue;
},
};
Expand All @@ -244,7 +245,7 @@ pub async fn get(name: String, context: Context) -> Result<impl Reply, Rejection
let body: String = match serde_json::to_string(&dataset) {
Ok(body) => body,
Err(source) => {
error!("{}", Error::SerializeError { what: "dataset metadata", source });
error!("{}", Error::SerializeError { what: "dataset metadata", source }.trace());
fail!();
},
};
Expand Down
27 changes: 14 additions & 13 deletions brane-api/src/infra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use brane_cfg::info::Info as _;
use brane_cfg::infra::{InfraFile, InfraLocation};
use brane_cfg::node::NodeConfig;
use brane_prx::spec::NewPathRequestTlsOptions;
use error_trace::{ErrorTrace as _, trace};
use log::{debug, error};
use specifications::address::Address;
use specifications::package::Capability;
Expand Down Expand Up @@ -47,7 +48,7 @@ pub async fn registries(context: Context) -> Result<impl Reply, Rejection> {
let node_config: NodeConfig = match NodeConfig::from_path(&context.node_config_path) {
Ok(config) => config,
Err(err) => {
error!("Failed to load NodeConfig file: {}", err);
error!("{}", trace!(("Failed to load NodeConfig file"), err));
return Err(warp::reject::custom(Error::SecretError));
},
};
Expand All @@ -60,7 +61,7 @@ pub async fn registries(context: Context) -> Result<impl Reply, Rejection> {
let infra: InfraFile = match InfraFile::from_path(&node_config.node.central().paths.infra) {
Ok(infra) => infra,
Err(source) => {
error!("{}", Error::InfrastructureOpenError { path: node_config.node.central().paths.infra.clone(), source });
error!("{}", Error::InfrastructureOpenError { path: node_config.node.central().paths.infra.clone(), source }.trace());
return Err(warp::reject::custom(Error::SecretError));
},
};
Expand All @@ -75,7 +76,7 @@ pub async fn registries(context: Context) -> Result<impl Reply, Rejection> {
let body: String = match serde_json::to_string(&locations) {
Ok(body) => body,
Err(source) => {
error!("{}", Error::SerializeError { what: "list of all registry endpoints", source });
error!("{}", Error::SerializeError { what: "list of all registry endpoints", source }.trace());
return Err(warp::reject::custom(Error::SecretError));
},
};
Expand Down Expand Up @@ -109,7 +110,7 @@ pub async fn get_registry(loc: String, context: Context) -> Result<impl Reply, R
let node_config: NodeConfig = match NodeConfig::from_path(&context.node_config_path) {
Ok(config) => config,
Err(err) => {
error!("Failed to load NodeConfig file: {}", err);
error!("{}", trace!(("Failed to load NodeConfig file"), err));
return Err(warp::reject::custom(Error::SecretError));
},
};
Expand All @@ -122,7 +123,7 @@ pub async fn get_registry(loc: String, context: Context) -> Result<impl Reply, R
let infra: InfraFile = match InfraFile::from_path(&node_config.node.central().paths.infra) {
Ok(infra) => infra,
Err(source) => {
error!("{}", Error::InfrastructureOpenError { path: node_config.node.central().paths.infra.clone(), source });
error!("{}", Error::InfrastructureOpenError { path: node_config.node.central().paths.infra.clone(), source }.trace());
return Err(warp::reject::custom(Error::SecretError));
},
};
Expand Down Expand Up @@ -167,7 +168,7 @@ pub async fn get_capabilities(loc: String, context: Context) -> Result<impl Repl
let node_config: NodeConfig = match NodeConfig::from_path(&context.node_config_path) {
Ok(config) => config,
Err(err) => {
error!("Failed to load NodeConfig file: {}", err);
error!("{}", trace!(("Failed to load NodeConfig file"), err));
return Err(warp::reject::custom(Error::SecretError));
},
};
Expand All @@ -180,7 +181,7 @@ pub async fn get_capabilities(loc: String, context: Context) -> Result<impl Repl
let infra: InfraFile = match InfraFile::from_path(&node_config.node.central().paths.infra) {
Ok(infra) => infra,
Err(source) => {
error!("{}", Error::InfrastructureOpenError { path: node_config.node.central().paths.infra.clone(), source });
error!("{}", Error::InfrastructureOpenError { path: node_config.node.central().paths.infra.clone(), source }.trace());
return Err(warp::reject::custom(Error::SecretError));
},
};
Expand All @@ -199,32 +200,32 @@ pub async fn get_capabilities(loc: String, context: Context) -> Result<impl Repl
Ok(res) => match res {
Ok(res) => res,
Err(source) => {
error!("{}", Error::RequestError { address: reg_addr, source });
error!("{}", Error::RequestError { address: reg_addr, source }.trace());
return Err(warp::reject::custom(Error::SecretError));
},
},
Err(source) => {
error!("{}", Error::ProxyError { source });
error!("{}", Error::ProxyError { source }.trace());
return Err(warp::reject::custom(Error::SecretError));
},
};
if !res.status().is_success() {
error!("{}", Error::RequestFailure { address: reg_addr, code: res.status(), message: res.text().await.ok() });
error!("{}", Error::RequestFailure { address: reg_addr, code: res.status(), message: res.text().await.ok() }.trace());
return Err(warp::reject::custom(Error::SecretError));
}

// Parse the body as the proper JSON
let capabilities: String = match res.text().await {
Ok(caps) => caps,
Err(source) => {
error!("{}", Error::ResponseBodyError { address: reg_addr, source });
error!("{}", Error::ResponseBodyError { address: reg_addr, source }.trace());
return Err(warp::reject::custom(Error::SecretError));
},
};
let capabilities: HashSet<Capability> = match serde_json::from_str(&capabilities) {
Ok(caps) => caps,
Err(source) => {
error!("{}", Error::ResponseParseError { address: reg_addr, raw: capabilities, source });
error!("{}", Error::ResponseParseError { address: reg_addr, raw: capabilities, source }.trace());
return Err(warp::reject::custom(Error::SecretError));
},
};
Expand All @@ -233,7 +234,7 @@ pub async fn get_capabilities(loc: String, context: Context) -> Result<impl Repl
let body: String = match serde_json::to_string(&capabilities) {
Ok(body) => body,
Err(source) => {
error!("{}", Error::CapabilitiesSerializeError { source });
error!("{}", Error::CapabilitiesSerializeError { source }.trace());
return Err(warp::reject::custom(Error::SecretError));
},
};
Expand Down
13 changes: 7 additions & 6 deletions brane-api/src/packages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use async_compression::tokio::bufread::GzipDecoder;
use brane_cfg::info::Info as _;
use brane_cfg::node::{CentralConfig, NodeConfig, NodeKind};
use bytes::Buf;
use error_trace::{ErrorTrace as _, trace};
use log::{debug, error, info, warn};
use rand::Rng;
use rand::distr::Alphanumeric;
Expand Down Expand Up @@ -59,7 +60,7 @@ macro_rules! fail {

// Now write the error to stderr and the internal error to the client
let err = $err;
error!("{}", err);
error!("{}", err.trace());
return Err(warp::reject::custom(InternalError));
}};

Expand All @@ -68,11 +69,11 @@ macro_rules! fail {
let path = &$path;
if path.is_file() {
if let Err(err) = tfs::remove_file(&path).await {
warn!("Failed to remove temporary download result '{}': {}", path.display(), err);
warn!("{}", trace!(("Failed to remove temporary download result '{}'", path.display()), err));
}
} else if path.is_dir() {
if let Err(err) = tfs::remove_dir_all(&path).await {
warn!("Failed to remove temporary download results '{}': {}", path.display(), err);
warn!("{}", trace!(("Failed to remove temporary download results '{}'", path.display()), err));
}
}

Expand Down Expand Up @@ -281,7 +282,7 @@ pub async fn download(name: String, version: String, context: Context) -> Result
match latest {
Some(version) => version,
None => {
error!("{}", Error::NoVersionsFound { name });
error!("{}", Error::NoVersionsFound { name }.trace());
return Err(warp::reject::not_found());
},
}
Expand All @@ -301,15 +302,15 @@ pub async fn download(name: String, version: String, context: Context) -> Result
Ok(file) => {
if let Some(rows) = file.rows {
if rows.is_empty() {
error!("{}", Error::UnknownPackage { name, version });
error!("{}", Error::UnknownPackage { name, version }.trace());
return Err(warp::reject::not_found());
}
if rows.len() > 1 {
panic!("Database contains {} entries with the same name & version ('{}' & '{}')", rows.len(), name, version);
}
rows[0].columns[0].as_ref().unwrap().as_text().unwrap().into()
} else {
error!("{}", Error::UnknownPackage { name, version });
error!("{}", Error::UnknownPackage { name, version }.trace());
return Err(warp::reject::not_found());
}
},
Expand Down
6 changes: 3 additions & 3 deletions brane-cli/src/build_ecu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,13 @@ async fn build(
/// * `context`: The directory to find the executable in.
/// * `override_branelet`: Whether or not to override the branelet executable. If so, assumes the new one is copied to the temporary build folder by the time the DockerFile is run.
///
/// **Returns**
/// **Returns**
/// A String that is the new DockerFile on success, or a BuildError otherwise.
fn generate_dockerfile(document: &ContainerInfo, context: &Path, override_branelet: bool) -> Result<String, BuildError> {
let mut contents = String::new();

// Get the base image from the document
let base = document.base.clone().unwrap_or_else(|| String::from("ubuntu:20.04"));
let base = document.base.clone().unwrap_or_else(|| String::from("ubuntu:24.04"));

// Add default heading
writeln_build!(contents, "# Generated by Brane")?;
Expand Down Expand Up @@ -268,7 +268,7 @@ fn generate_dockerfile(document: &ContainerInfo, context: &Path, override_branel
/// * `package_dir`: The directory where we can build the package and store it once done.
/// - `convert_crlf`: If true, will not ask to convert CRLF files but instead just do it.
///
/// **Returns**
/// **Returns**
/// Nothing if the directory was created successfully, or a BuildError otherwise.
fn prepare_directory(
document: &ContainerInfo,
Expand Down
Loading