From afe60452261c468ecb79178c761c08ae8442ca65 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 15 Feb 2024 11:29:44 -0800 Subject: [PATCH] Add logging for missing blob store env vars Co-authored-by: Marshall --- crates/collab/src/api/extensions.rs | 2 ++ crates/collab/src/lib.rs | 32 ++++++++++++++++++++++------- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/crates/collab/src/api/extensions.rs b/crates/collab/src/api/extensions.rs index 66b713dadc40a..5cf211f972d12 100644 --- a/crates/collab/src/api/extensions.rs +++ b/crates/collab/src/api/extensions.rs @@ -110,9 +110,11 @@ const EXTENSION_DOWNLOAD_URL_LIFETIME: Duration = Duration::from_secs(3 * 60); pub fn fetch_extensions_from_blob_store_periodically(app_state: Arc, executor: Executor) { let Some(blob_store_client) = app_state.blob_store_client.clone() else { + log::info!("no blob store client"); return; }; let Some(blob_store_bucket) = app_state.config.blob_store_bucket.clone() else { + log::info!("no blob store bucket"); return; }; diff --git a/crates/collab/src/lib.rs b/crates/collab/src/lib.rs index 919acdb36a25a..195ed7b11d9b2 100644 --- a/crates/collab/src/lib.rs +++ b/crates/collab/src/lib.rs @@ -8,12 +8,14 @@ pub mod rpc; #[cfg(test)] mod tests; +use anyhow::anyhow; use aws_config::{BehaviorVersion, Region}; use axum::{http::StatusCode, response::IntoResponse}; use db::Database; use executor::Executor; use serde::Deserialize; use std::{path::PathBuf, sync::Arc}; +use util::ResultExt; pub type Result = std::result::Result; @@ -153,28 +155,44 @@ impl AppState { let this = Self { db: Arc::new(db), live_kit_client, - blob_store_client: build_blob_store_client(&config).await, + blob_store_client: build_blob_store_client(&config).await.log_err(), config, }; Ok(Arc::new(this)) } } -async fn build_blob_store_client(config: &Config) -> Option { +async fn build_blob_store_client(config: &Config) -> anyhow::Result { let keys = aws_sdk_s3::config::Credentials::new( - config.blob_store_access_key.clone()?, - config.blob_store_secret_key.clone()?, + config + .blob_store_access_key + .clone() + .ok_or_else(|| anyhow!("missing blob_store_access_key"))?, + config + .blob_store_secret_key + .clone() + .ok_or_else(|| anyhow!("missing blob_store_secret_key"))?, None, None, "env", ); let s3_config = aws_config::defaults(BehaviorVersion::latest()) - .endpoint_url(config.blob_store_url.as_ref()?) - .region(Region::new(config.blob_store_region.clone()?)) + .endpoint_url( + config + .blob_store_url + .as_ref() + .ok_or_else(|| anyhow!("missing blob_store_url"))?, + ) + .region(Region::new( + config + .blob_store_region + .clone() + .ok_or_else(|| anyhow!("missing blob_store_region"))?, + )) .credentials_provider(keys) .load() .await; - Some(aws_sdk_s3::Client::new(&s3_config)) + Ok(aws_sdk_s3::Client::new(&s3_config)) }