From fdd11a71f6cd121666c4c36129ee0a01e5758baa Mon Sep 17 00:00:00 2001 From: jonaro00 <54029719+jonaro00@users.noreply.github.com> Date: Wed, 8 May 2024 13:52:04 +0200 Subject: [PATCH 1/3] fix: otel-otlp features for http client --- Cargo.lock | 3 +++ Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 40adb12c8..fa24ba82d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3911,6 +3911,7 @@ dependencies = [ "bytes", "http 0.2.12", "opentelemetry 0.21.0", + "reqwest 0.11.27", ] [[package]] @@ -3928,6 +3929,7 @@ dependencies = [ "opentelemetry-semantic-conventions", "opentelemetry_sdk", "prost 0.11.9", + "reqwest 0.11.27", "thiserror", "tokio", "tonic 0.9.2", @@ -4590,6 +4592,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "rustls 0.21.11", + "rustls-native-certs", "rustls-pemfile 1.0.4", "serde", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index 35d38d1ab..f77f1ed01 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,7 +68,7 @@ once_cell = "1.16.0" opentelemetry = "0.21.0" opentelemetry_sdk = { version = "0.21.0", features = ["rt-tokio", "logs"] } opentelemetry-http = "0.10.0" -opentelemetry-otlp = { version = "0.14.0", features = ["logs", "grpc-tonic", "http-proto"] } +opentelemetry-otlp = { version = "0.14.0", features = ["logs", "http-proto", "reqwest-client", "reqwest-rustls"] } opentelemetry-proto = "0.4.0" opentelemetry-contrib = { version = "0.4.0", features = ["datadog"] } opentelemetry-appender-tracing = "0.2.0" From 38fec34ac05e6dd7dba4230160b99547ae356cbf Mon Sep 17 00:00:00 2001 From: jonaro00 <54029719+jonaro00@users.noreply.github.com> Date: Wed, 8 May 2024 14:45:07 +0200 Subject: [PATCH 2/3] fix: otel collector http port --- backends/src/trace.rs | 2 +- docker-compose.dev.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/backends/src/trace.rs b/backends/src/trace.rs index d41bea16b..813ceaf46 100644 --- a/backends/src/trace.rs +++ b/backends/src/trace.rs @@ -10,7 +10,7 @@ use shuttle_common::log::Backend; use super::otlp_tracing_bridge::{self, ErrorTracingLayer}; -const OTLP_ADDRESS: &str = "http://otel-collector:4317"; +const OTLP_ADDRESS: &str = "http://otel-collector:4318"; pub fn setup_tracing(subscriber: S, backend: Backend) where diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 6d4c58dd9..4706a2ea5 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -97,6 +97,7 @@ services: otel-collector: ports: - 4317:4317 + - 4318:4318 logger: ports: - 8010:8000 From fb737cbe4da0d737c554aef5bcd65edaf541475e Mon Sep 17 00:00:00 2001 From: jonaro00 <54029719+jonaro00@users.noreply.github.com> Date: Wed, 8 May 2024 15:11:09 +0200 Subject: [PATCH 3/3] fix: deployment request fields ser/de --- cargo-shuttle/src/client.rs | 4 ++-- cargo-shuttle/src/lib.rs | 16 ++++++++++++---- common/src/models/deployment.rs | 22 ++++++++++++++++------ 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/cargo-shuttle/src/client.rs b/cargo-shuttle/src/client.rs index 72f677f9b..036d42802 100644 --- a/cargo-shuttle/src/client.rs +++ b/cargo-shuttle/src/client.rs @@ -9,7 +9,7 @@ use reqwest::{RequestBuilder, Response}; use serde::{Deserialize, Serialize}; use shuttle_common::constants::headers::X_CARGO_SHUTTLE_VERSION; use shuttle_common::log::LogsRange; -use shuttle_common::models::deployment::DeploymentRequest; +use shuttle_common::models::deployment::{DeploymentRequest, DeploymentRequestBeta}; use shuttle_common::models::team; use shuttle_common::models::{deployment, project, service, ToJson}; use shuttle_common::{resource, ApiKey, LogItem, VersionInfo}; @@ -108,7 +108,7 @@ impl ShuttleApiClient { pub async fn deploy_beta( &self, project: &str, - deployment_req: DeploymentRequest, + deployment_req: DeploymentRequestBeta, ) -> Result { let path = format!("/projects/{project}"); let deployment_req = rmp_serde::to_vec(&deployment_req) diff --git a/cargo-shuttle/src/lib.rs b/cargo-shuttle/src/lib.rs index 8f06fbd8c..528949d79 100644 --- a/cargo-shuttle/src/lib.rs +++ b/cargo-shuttle/src/lib.rs @@ -32,7 +32,7 @@ use ignore::overrides::OverrideBuilder; use ignore::WalkBuilder; use indicatif::ProgressBar; use indoc::{formatdoc, printdoc}; -use shuttle_common::models::deployment::deployments_table_beta; +use shuttle_common::models::deployment::{deployments_table_beta, DeploymentRequestBeta}; use shuttle_common::{ constants::{ API_URL_DEFAULT, DEFAULT_IDLE_MINUTES, EXAMPLES_REPO, EXECUTABLE_DIRNAME, @@ -1756,6 +1756,9 @@ impl Shuttle { no_test: args.no_test, ..Default::default() }; + let mut deployment_req_beta = DeploymentRequestBeta { + ..Default::default() + }; if self.beta { let manifest_path = working_directory.join("Cargo.toml"); @@ -1779,7 +1782,7 @@ impl Shuttle { trace!(keys = ?secrets.keys(), "available secrets"); - deployment_req.secrets = Some(secrets); + deployment_req_beta.secrets = Some(secrets); } else { trace!("No secrets were loaded"); } @@ -1794,7 +1797,7 @@ impl Shuttle { .expect("at least one shuttle crate in the workspace") .name .to_owned(); - deployment_req.package_name = Some(package_name); + deployment_req_beta.package_name = package_name; } if let Ok(repo) = Repository::discover(working_directory) { @@ -1839,8 +1842,13 @@ impl Shuttle { // End this early for beta platform. if self.beta { + deployment_req_beta.data = deployment_req.data; + deployment_req_beta.git_commit_id = deployment_req.git_commit_id; + deployment_req_beta.git_commit_msg = deployment_req.git_commit_msg; + deployment_req_beta.git_branch = deployment_req.git_branch; + deployment_req_beta.git_dirty = deployment_req.git_dirty; let deployment = client - .deploy_beta(self.ctx.project_name(), deployment_req) + .deploy_beta(self.ctx.project_name(), deployment_req_beta) .await .map_err(suggestions::deploy::deploy_request_failure)?; diff --git a/common/src/models/deployment.rs b/common/src/models/deployment.rs index 29c848ae3..1c5bfe1f9 100644 --- a/common/src/models/deployment.rs +++ b/common/src/models/deployment.rs @@ -409,16 +409,26 @@ pub fn get_deployments_table( #[derive(Default, Deserialize, Serialize)] pub struct DeploymentRequest { - /// Alpha: tar archive. Beta: zip archive. + /// Alpha: tar archive. pub data: Vec, - /// The cargo package name to compile and run. Required on beta. - pub package_name: Option, - /// Secrets to add before this deployment. Ignored on alpha. - pub secrets: Option>, - /// Ignored on beta. pub no_test: bool, pub git_commit_id: Option, pub git_commit_msg: Option, pub git_branch: Option, pub git_dirty: Option, } + +#[derive(Default, Deserialize, Serialize)] +pub struct DeploymentRequestBeta { + /// Beta: zip archive. + pub data: Vec, + /// The cargo package name to compile and run. + pub package_name: String, + /// Secrets to add before this deployment. + /// Might remove this in favour of a separate secrets uploading action. + pub secrets: Option>, + pub git_commit_id: Option, + pub git_commit_msg: Option, + pub git_branch: Option, + pub git_dirty: Option, +}