Skip to content

Commit

Permalink
fix: error handling on server start when s3 bucket is not found (#609)
Browse files Browse the repository at this point in the history
fixes #574
  • Loading branch information
gurjotkaur20 authored Jan 10, 2024
1 parent 238b9ae commit 26b2ec0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
4 changes: 4 additions & 0 deletions server/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ pub enum ObjectStorageError {
#[error("{0} not found")]
NoSuchKey(String),

// custom
#[error("{0}")]
Custom(String),

// Could not connect to object storage
#[error("Connection Error: {0}")]
ConnectionError(Box<dyn std::error::Error + Send + Sync + 'static>),
Expand Down
9 changes: 9 additions & 0 deletions server/src/storage/s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,15 @@ impl S3 {
.with_label_values(&["PUT", status])
.observe(time);

if let Err(object_store::Error::NotFound { source, .. }) = &resp {
let source_str = source.to_string();
if source_str.contains("<Code>NoSuchBucket</Code>") {
return Err(ObjectStorageError::Custom(
format!("Bucket '{}' does not exist in S3.", self.bucket).to_string(),
));
}
}

resp.map(|_| ()).map_err(|err| err.into())
}

Expand Down
8 changes: 4 additions & 4 deletions server/src/storage/store_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,14 @@ pub async fn resolve_parseable_metadata() -> Result<StorageMetadata, ObjectStora
ObjectStorageError::UnhandledError(err)
})?;

if overwrite_staging {
put_staging_metadata(&metadata)?;
}

if overwrite_remote {
put_remote_metadata(&metadata).await?;
}

if overwrite_staging {
put_staging_metadata(&metadata)?;
}

Ok(metadata)
}

Expand Down

0 comments on commit 26b2ec0

Please sign in to comment.