From e7af006c1c8211bf83b5d8abb7490ef270dd8345 Mon Sep 17 00:00:00 2001 From: Jakub Jirutka Date: Sat, 3 Sep 2022 23:40:44 +0200 Subject: Make OTLP exporter optional via feature "telemetry-otlp" opentelemetry-otlp add 48 (!) extra dependencies and increases the size of the garage binary by ~11 % (with fat LTO). --- src/garage/main.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/garage/main.rs') diff --git a/src/garage/main.rs b/src/garage/main.rs index 89888884..8f0b377e 100644 --- a/src/garage/main.rs +++ b/src/garage/main.rs @@ -8,6 +8,7 @@ mod admin; mod cli; mod repair; mod server; +#[cfg(feature = "telemetry-otlp")] mod tracing_setup; use std::net::SocketAddr; -- cgit v1.2.3 From db61f41030678c5756c844c8aa41a210c658769e Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Wed, 7 Sep 2022 11:59:56 +0200 Subject: Move GIT_VERSION injection later in build chain to reduce build times --- src/garage/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/garage/main.rs') diff --git a/src/garage/main.rs b/src/garage/main.rs index 8f0b377e..94c9bf61 100644 --- a/src/garage/main.rs +++ b/src/garage/main.rs @@ -23,15 +23,15 @@ use garage_util::error::*; use garage_rpc::system::*; use garage_rpc::*; -use garage_util::version; use garage_model::helper::error::Error as HelperError; +use garage_model::version::garage_version; use admin::*; use cli::*; #[derive(StructOpt, Debug)] -#[structopt(name = "garage", version = version::garage(), about = "S3-compatible object store for self-hosted geo-distributed deployments")] +#[structopt(name = "garage", version = garage_version(), about = "S3-compatible object store for self-hosted geo-distributed deployments")] struct Opt { /// Host to connect to for admin operations, in the format: /// @: -- cgit v1.2.3 From 28d86e76021bed674ca78684b9522cfb664a8ae2 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Wed, 7 Sep 2022 17:05:21 +0200 Subject: Report build features in garage --help --- src/garage/main.rs | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'src/garage/main.rs') diff --git a/src/garage/main.rs b/src/garage/main.rs index 94c9bf61..7d00811a 100644 --- a/src/garage/main.rs +++ b/src/garage/main.rs @@ -25,13 +25,15 @@ use garage_rpc::system::*; use garage_rpc::*; use garage_model::helper::error::Error as HelperError; -use garage_model::version::garage_version; use admin::*; use cli::*; #[derive(StructOpt, Debug)] -#[structopt(name = "garage", version = garage_version(), about = "S3-compatible object store for self-hosted geo-distributed deployments")] +#[structopt( + name = "garage", + about = "S3-compatible object store for self-hosted geo-distributed deployments" +)] struct Opt { /// Host to connect to for admin operations, in the format: /// @: @@ -69,7 +71,35 @@ async fn main() { std::process::abort(); })); - let opt = Opt::from_args(); + // Parse opt + let features = &[ + #[cfg(feature = "k2v")] + "k2v", + #[cfg(feature = "sled")] + "sled", + #[cfg(feature = "lmdb")] + "lmdb", + #[cfg(feature = "sqlite")] + "sqlite", + #[cfg(feature = "kubernetes-discovery")] + "kubernetes-discovery", + #[cfg(feature = "metrics")] + "metrics", + #[cfg(feature = "telemetry-otlp")] + "telemetry-otlp", + #[cfg(feature = "bundled-libs")] + "bundled-libs", + #[cfg(feature = "system-libs")] + "system-libs", + ][..]; + let version = format!( + "{} [features: {}]", + garage_model::version::garage_version(), + features.join(", ") + ); + garage_model::version::init_features(features); + let opt = Opt::from_clap(&Opt::clap().version(version.as_str()).get_matches()); + let res = match opt.cmd { Command::Server => server::run_server(opt.config_file).await, Command::OfflineRepair(repair_opt) => { -- cgit v1.2.3 From 2e00809af58c142c86fae5f4bad85c4ef5e57872 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Wed, 7 Sep 2022 17:57:12 +0200 Subject: Error messages when system-libs XOR bundled-libs != 1 --- src/garage/main.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/garage/main.rs') diff --git a/src/garage/main.rs b/src/garage/main.rs index 7d00811a..751dd941 100644 --- a/src/garage/main.rs +++ b/src/garage/main.rs @@ -11,6 +11,12 @@ mod server; #[cfg(feature = "telemetry-otlp")] mod tracing_setup; +#[cfg(not(any(feature = "bundled-libs", feature = "system-libs")))] +compile_error!("Either bundled-libs or system-libs Cargo feature must be enabled"); + +#[cfg(all(feature = "bundled-libs", feature = "system-libs"))] +compile_error!("Only one of bundled-libs and system-libs Cargo features must be enabled"); + use std::net::SocketAddr; use std::path::PathBuf; -- cgit v1.2.3 From f310fce34b0273f9f75e7a6ea665f51003a1f795 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Wed, 7 Sep 2022 18:30:15 +0200 Subject: Inject GIT_VERSION even later --- src/garage/main.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/garage/main.rs') diff --git a/src/garage/main.rs b/src/garage/main.rs index 751dd941..1a4a939a 100644 --- a/src/garage/main.rs +++ b/src/garage/main.rs @@ -77,7 +77,7 @@ async fn main() { std::process::abort(); })); - // Parse opt + // Initialize version and features info let features = &[ #[cfg(feature = "k2v")] "k2v", @@ -98,12 +98,17 @@ async fn main() { #[cfg(feature = "system-libs")] "system-libs", ][..]; + if let Some(git_version) = option_env!("GIT_VERSION") { + garage_model::version::init_version(git_version); + } + garage_model::version::init_features(features); + + // Parse arguments let version = format!( "{} [features: {}]", garage_model::version::garage_version(), features.join(", ") ); - garage_model::version::init_features(features); let opt = Opt::from_clap(&Opt::clap().version(version.as_str()).get_matches()); let res = match opt.cmd { -- cgit v1.2.3 From ceb1f0229a9c8b9f8255b4a4c70272627f0c34d7 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Wed, 7 Sep 2022 18:36:46 +0200 Subject: Move version back into util --- src/garage/main.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/garage/main.rs') diff --git a/src/garage/main.rs b/src/garage/main.rs index 1a4a939a..77d5db24 100644 --- a/src/garage/main.rs +++ b/src/garage/main.rs @@ -99,14 +99,14 @@ async fn main() { "system-libs", ][..]; if let Some(git_version) = option_env!("GIT_VERSION") { - garage_model::version::init_version(git_version); + garage_util::version::init_version(git_version); } - garage_model::version::init_features(features); + garage_util::version::init_features(features); // Parse arguments let version = format!( "{} [features: {}]", - garage_model::version::garage_version(), + garage_util::version::garage_version(), features.join(", ") ); let opt = Opt::from_clap(&Opt::clap().version(version.as_str()).get_matches()); -- cgit v1.2.3