aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/api/admin/cluster.rs2
-rw-r--r--src/garage/admin.rs5
-rw-r--r--src/garage/main.rs36
-rw-r--r--src/model/Cargo.toml1
-rw-r--r--src/model/version.rs16
5 files changed, 56 insertions, 4 deletions
diff --git a/src/api/admin/cluster.rs b/src/api/admin/cluster.rs
index 8e6dfb3f..010382f2 100644
--- a/src/api/admin/cluster.rs
+++ b/src/api/admin/cluster.rs
@@ -19,6 +19,7 @@ pub async fn handle_get_cluster_status(garage: &Arc<Garage>) -> Result<Response<
let res = GetClusterStatusResponse {
node: hex::encode(garage.system.id),
garage_version: garage_model::version::garage_version(),
+ garage_features: garage_model::version::garage_features(),
db_engine: garage.db.engine(),
known_nodes: garage
.system
@@ -99,6 +100,7 @@ fn get_cluster_layout(garage: &Arc<Garage>) -> GetClusterLayoutResponse {
struct GetClusterStatusResponse {
node: String,
garage_version: &'static str,
+ garage_features: Option<&'static [&'static str]>,
db_engine: String,
known_nodes: HashMap<String, KnownNodeResp>,
layout: GetClusterLayoutResponse,
diff --git a/src/garage/admin.rs b/src/garage/admin.rs
index f4c182fe..8854a58d 100644
--- a/src/garage/admin.rs
+++ b/src/garage/admin.rs
@@ -739,8 +739,11 @@ impl AdminRpcHandler {
let mut ret = String::new();
writeln!(
&mut ret,
- "\nGarage version: {}",
+ "\nGarage version: {} [features: {}]",
garage_model::version::garage_version(),
+ garage_model::version::garage_features()
+ .map(|list| list.join(", "))
+ .unwrap_or_else(|| "(unknown)".into()),
)
.unwrap();
writeln!(&mut ret, "\nDatabase engine: {}", self.garage.db.engine()).unwrap();
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:
/// <public-key>@<ip>:<port>
@@ -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) => {
diff --git a/src/model/Cargo.toml b/src/model/Cargo.toml
index c41d3f16..101c97d3 100644
--- a/src/model/Cargo.toml
+++ b/src/model/Cargo.toml
@@ -26,6 +26,7 @@ blake2 = "0.9"
err-derive = "0.3"
git-version = "0.3.4"
hex = "0.4"
+lazy_static = "1.4"
base64 = "0.13"
tracing = "0.1.30"
rand = "0.8"
diff --git a/src/model/version.rs b/src/model/version.rs
index cdb3ea62..af6aa809 100644
--- a/src/model/version.rs
+++ b/src/model/version.rs
@@ -1,3 +1,11 @@
+use std::sync::Arc;
+
+use arc_swap::ArcSwapOption;
+
+lazy_static::lazy_static! {
+ static ref FEATURES: ArcSwapOption<&'static [&'static str]> = ArcSwapOption::new(None);
+}
+
pub fn garage_version() -> &'static str {
option_env!("GIT_VERSION").unwrap_or(git_version::git_version!(
prefix = "git:",
@@ -5,3 +13,11 @@ pub fn garage_version() -> &'static str {
fallback = "unknown"
))
}
+
+pub fn garage_features() -> Option<&'static [&'static str]> {
+ FEATURES.load().as_ref().map(|f| &f[..])
+}
+
+pub fn init_features(features: &'static [&'static str]) {
+ FEATURES.store(Some(Arc::new(features)));
+}