Skip to content

Commit 19595f6

Browse files
authored
[CHORE] Wire up auth for spanner in log-service. (#6228)
## Description of changes The `with_auth` call was missing. The rest is for making the code compile. ## Test plan CI ## Migration plan N/A ## Observability plan N/A ## Documentation Changes N/A
1 parent 287896c commit 19595f6

1 file changed

Lines changed: 18 additions & 10 deletions

File tree

rust/log-service/src/lib.rs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ pub enum Error {
140140
PreferredRegionNotInTopology(String),
141141
#[error("spanner error: {0}")]
142142
SpannerError(#[from] google_cloud_spanner::client::Error),
143+
// NOTE(rescrv): Intentionally don't print the error here. Log at initial time.
144+
#[error("spanner auth error")]
145+
SpannerAuthError(#[from] google_cloud_spanner::admin::google_cloud_auth::error::Error),
143146
}
144147

145148
impl ChromaError for Error {
@@ -155,6 +158,7 @@ impl ChromaError for Error {
155158
Error::MissingTopology(_) => chroma_error::ErrorCodes::Internal,
156159
Error::PreferredRegionNotInTopology(_) => chroma_error::ErrorCodes::InvalidArgument,
157160
Error::SpannerError(_) => chroma_error::ErrorCodes::Internal,
161+
Error::SpannerAuthError(_) => chroma_error::ErrorCodes::Internal,
158162
}
159163
}
160164
}
@@ -3049,24 +3053,28 @@ impl Configurable<LogServerConfig> for LogServer {
30493053
storage: Storage::try_from_config(&r.storage, registry).await?,
30503054
})
30513055
},
3052-
|t| {
3056+
|t| async move {
30533057
let database_path = t.spanner.database_path().clone();
30543058
let config = match t.spanner {
30553059
SpannerConfig::Emulator(e) => SpannerClientConfig {
30563060
environment: Environment::Emulator(e.grpc_endpoint()),
30573061
..Default::default()
30583062
},
3059-
SpannerConfig::Gcp(_) => Default::default(),
3063+
SpannerConfig::Gcp(_) => SpannerClientConfig::default()
3064+
.with_auth()
3065+
.await
3066+
.map_err(|e| -> Box<dyn ChromaError> {
3067+
tracing::event!(Level::ERROR, name = "auth error", error =? e);
3068+
Box::new(std::convert::Into::<Error>::into(e)) as _
3069+
})?,
30603070
};
30613071
let repl = t.repl.clone();
3062-
async {
3063-
Ok::<TopologicalStorage, Box<dyn ChromaError>>(TopologicalStorage {
3064-
spanner: SpannerClient::new(database_path, config).await.map_err(
3065-
|e| -> Box<dyn ChromaError> { Box::new(Error::from(e)) as _ },
3066-
)?,
3067-
repl,
3068-
})
3069-
}
3072+
Ok::<TopologicalStorage, Box<dyn ChromaError>>(TopologicalStorage {
3073+
spanner: SpannerClient::new(database_path, config).await.map_err(
3074+
|e| -> Box<dyn ChromaError> { Box::new(Error::from(e)) as _ },
3075+
)?,
3076+
repl,
3077+
})
30703078
},
30713079
)
30723080
.await?;

0 commit comments

Comments
 (0)