Skip to content

Commit

Permalink
Treat 404 as bucket doesn't exist
Browse files Browse the repository at this point in the history
Previously the fog distribution resync logic would only look for missing
keys. Now it handles a missing bucket or 404.
  • Loading branch information
nick-mobilecoin committed Oct 23, 2024
1 parent d2aa66b commit 910fad0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ledger/distribution/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use mc_ledger_db::{Ledger, LedgerDB};
use mc_util_telemetry::{mark_span_as_active, start_block_span, tracer, Tracer};
use protobuf::Message;
use retry::{delay, retry, OperationResult};
use rusoto_core::{Region, RusotoError};
use rusoto_core::{request::BufferedHttpResponse, Region, RusotoError};
use rusoto_s3::{HeadObjectError, HeadObjectRequest, PutObjectRequest, S3Client, S3};
use serde::{Deserialize, Serialize};
use std::{fs, path::PathBuf};
Expand Down Expand Up @@ -212,6 +212,13 @@ impl BlockHandler for S3BlockWriter {
Err(RusotoError::Service(HeadObjectError::NoSuchKey(_))) => {
OperationResult::Ok(false)
}
// Happens when the bucket itself doesn't exist
// Separate from the above condition for the `status.as_u16()` logic
Err(RusotoError::Unknown(BufferedHttpResponse { status, .. }))
if status.as_u16() == 404 =>
{
OperationResult::Ok(false)
}
Err(e) => {
log::warn!(self.logger, "Failed to talk to S3 {e:?}, retrying...");
OperationResult::Retry(e)
Expand Down

0 comments on commit 910fad0

Please sign in to comment.