Skip to content
Draft
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
64 changes: 32 additions & 32 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ directories = "6.0"
futures-core = "0.3.31"
futures-util = "0.3.31"
indexmap = { version = "2.1.0", features = ["serde"] }
miette = { version = "7", features = ["fancy"] }
miette = { version = "7.5", features = ["fancy"] }
mockall = "0.13.1"
multitool-sdk = { git = "https://github.com/wack/multitool-rust-sdk.git", branch = "trunk" }
pingora = { version = "0.3", features = ["lb", "proxy"], optional = true }
Expand Down
28 changes: 6 additions & 22 deletions src/adapters/ingresses/apig.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use async_trait::async_trait;
use bon::bon;
use miette::{Result, miette};
use miette::{Result, WrapErr, miette};
use tracing::{debug, info};

use crate::{
Shutdownable, WholePercent, subsystems::ShutdownResult, utils::load_default_aws_config,
Shutdownable, WholePercent,
subsystems::ShutdownResult,
utils::{load_default_aws_config, map_aws_error},
};

use aws_sdk_apigateway::{
Expand Down Expand Up @@ -201,26 +203,8 @@ impl Ingress for AwsApiGateway {
.principal("apigateway.amazonaws.com")
.send()
.await
.map_err(|err| {
let error_message = match err {
SdkError::ServiceError(service_err) => {
// Extract the specific service error details
format!(
"{}",
service_err
.err()
.meta()
.message()
.unwrap_or("No error message found")
)
}
_ => format!("{:?}", err),
};
miette!(
"Failed to add invoke permission to Lambda: {}",
error_message
)
})?;
.map_err(map_aws_error)
.wrap_err_with(|| "Failed to add invoke permission to Lambda")?;

// Update our API Gateway to point at our new lambda version
let patch_op = PatchOperation::builder()
Expand Down
26 changes: 7 additions & 19 deletions src/adapters/platforms/lambda.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
use async_trait::async_trait;
use bon::bon;
use miette::{Result, miette};
use miette::{Result, WrapErr, miette};
use tracing::info;

use crate::{
Shutdownable, artifacts::LambdaZip, subsystems::ShutdownResult, utils::load_default_aws_config,
Shutdownable,
artifacts::LambdaZip,
subsystems::ShutdownResult,
utils::{load_default_aws_config, map_aws_error},
};
use aws_sdk_lambda::{client::Client, error::SdkError, primitives::Blob, types::FunctionCode};

Expand Down Expand Up @@ -58,23 +61,8 @@ impl Platform for LambdaPlatform {
.zip_file(zip_file.clone())
.send()
.await
.map_err(|err| {
let error_message = match err {
SdkError::ServiceError(service_err) => {
// Extract the specific service error details
format!(
"{}",
service_err
.err()
.meta()
.message()
.unwrap_or("No error message found")
)
}
_ => format!("{:?}", err),
};
miette!("Failed to deploy Lambda: {}", error_message)
})?;
.map_err(map_aws_error)
.wrap_err("Failed to deploy lambda")?;

let function_arn = res
.function_arn()
Expand Down
28 changes: 26 additions & 2 deletions src/cmd/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ use crate::subsystems::CONTROLLER_SUBSYSTEM_NAME;
use crate::{
ControllerSubsystem, adapters::BackendClient, artifacts::LambdaZip, config::RunSubcommand,
};
use miette::Result;
use miette::{Diagnostic, Result};
use thiserror::Error;
use tokio::runtime::Runtime;
use tokio::time::Duration;
use tokio_graceful_shutdown::errors::GracefulShutdownError::ShutdownTimeout;
use tokio_graceful_shutdown::errors::GracefulShutdownError::SubsystemsFailed;
use tokio_graceful_shutdown::errors::SubsystemError;
use tokio_graceful_shutdown::{IntoSubsystem as _, SubsystemBuilder, Toplevel};
use tracing::{debug, info};

Expand All @@ -30,6 +34,21 @@ pub struct Run {
backend: BackendClient,
}

#[derive(Debug, Error, Diagnostic)]
#[error("Rollout failed to complete successfully.")]
pub struct RunError {
#[related]
subsystem_errors: Vec<SubsystemError>,
}

impl<T: IntoIterator<Item = SubsystemError>> From<T> for RunError {
fn from(subsystem_errors: T) -> Self {
Self {
subsystem_errors: subsystem_errors.into_iter().collect(),
}
}
}

impl Run {
pub fn new(terminal: Terminal, args: RunSubcommand) -> Result<Self> {
let fs = FileSystem::new().unwrap();
Expand Down Expand Up @@ -105,7 +124,12 @@ impl Run {
.catch_signals()
.handle_shutdown_requests(Duration::from_millis(DEFAULT_SHUTDOWN_TIMEOUT))
.await
.map_err(Into::into)
.map_err(|err| match err {
SubsystemsFailed(errs) => RunError::from(errs),
ShutdownTimeout(errs) => RunError::from(errs),
})?;

Ok(())
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/terminal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl Terminal {
miette::set_hook(Box::new(move |_| {
if allow_color {
// TODO: Add brand colors using ``::new_themed()`
Box::new(GraphicalReportHandler::new())
Box::new(GraphicalReportHandler::new().with_cause_chain())
} else {
Box::new(DebugReportHandler)
}
Expand Down
Loading
Loading