diff --git a/.github/workflows/docker-build-push.yml b/.github/workflows/docker-build-push.yml index 72a8b41b..d8f69c0f 100644 --- a/.github/workflows/docker-build-push.yml +++ b/.github/workflows/docker-build-push.yml @@ -18,6 +18,6 @@ jobs: dockerfile: docker/p2p.dockerfile # name of the docker image image_name: p2p-demo -# push: 'true' + push: 'true' docker_cache_enabled: true secrets: inherit diff --git a/Cargo.lock b/Cargo.lock index 7159c02f..8c1096ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -884,6 +884,7 @@ dependencies = [ "strum", "strum_macros", "thiserror", + "time 0.3.21", "tokio", "tower", "uuid 1.3.2", diff --git a/cml-protocol/Cargo.toml b/cml-protocol/Cargo.toml index 86955494..b5bad1ae 100644 --- a/cml-protocol/Cargo.toml +++ b/cml-protocol/Cargo.toml @@ -31,8 +31,8 @@ serde_json = "1.0.96" thiserror = "1.0.40" tokio = { version = "1.28.0", features = ["time", "macros", "signal"] } uuid = { version = "1.3.2", features = ["serde"] } +time = { version = "0.3.21", features = ["std", "serde-human-readable", "parsing"] } -cml-core = { path = "../cml-core" } strum_macros = "0.24.3" prometheus-client = "0.20.0" strum = "0.24.1" @@ -40,3 +40,5 @@ base64 = "0.21.0" rand = "0.8.5" tower = "0.4.13" pin-project = "1.0.12" + +cml-core = { path = "../cml-core" } diff --git a/cml-protocol/src/resource/mod.rs b/cml-protocol/src/resource/mod.rs index 8cf19510..607cbefe 100644 --- a/cml-protocol/src/resource/mod.rs +++ b/cml-protocol/src/resource/mod.rs @@ -5,6 +5,7 @@ use deployment::{CreateDeploymentRequest, GetDeploymentResponse, GetDeploymentSt use reqwest::StatusCode; use reservation::{CreateReservationRequest, ReservationInfo}; use thiserror::Error; +use time::OffsetDateTime; use uuid::Uuid; pub mod deployment; @@ -15,12 +16,12 @@ pub enum ResourceError { #[error("error occurred while querying the resource manager: {0}")] Request(#[from] reqwest::Error), - #[error("allocation failed with the following status code: {0}")] - Allocation(StatusCode), - #[error("resource {0} with ID {1} not found")] NotFound(String, Uuid), + #[error("allocation failed with the following status code: {0}")] + Allocation(StatusCode), + #[error("the resource manager returned the following status code: {0}")] Manager(StatusCode), @@ -30,8 +31,8 @@ pub enum ResourceError { #[error("unknown reservation status: {0}")] UnknownReservationStatus(#[from] strum::ParseError), - #[error("an error occurred: {0}")] - Custom(String), + #[error("an error occurred: {0} at {1}")] + Custom(String, OffsetDateTime), } #[async_trait] diff --git a/p2p-app/src/resource/error.rs b/p2p-app/src/resource/error.rs index 26e8073a..fde0a697 100644 --- a/p2p-app/src/resource/error.rs +++ b/p2p-app/src/resource/error.rs @@ -5,13 +5,16 @@ use time::OffsetDateTime; #[derive(Debug, Deserialize)] pub struct ErrorResponse { error: String, - fields: Vec, + fields: Option>, #[serde(with = "time::serde::rfc3339")] time: OffsetDateTime, } impl From for ResourceError { fn from(error: ErrorResponse) -> Self { - ResourceError::Custom(format!("operation failed {} at {}", error.error, error.time)) + match error.fields { + None => ResourceError::Custom(error.error, error.time), + Some(f) => ResourceError::Custom(format!("{}, fields {f:?}", error.error), error.time), + } } }