From 1b837c343208c6b83a3b61a9ef74cd5042a103dc Mon Sep 17 00:00:00 2001 From: Nick Santana Date: Thu, 24 Oct 2024 10:05:30 -0700 Subject: [PATCH] Fix ledger distribution resync (#4013) --- ledger/distribution/src/main.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ledger/distribution/src/main.rs b/ledger/distribution/src/main.rs index 70545764bc..b14cb4bc49 100644 --- a/ledger/distribution/src/main.rs +++ b/ledger/distribution/src/main.rs @@ -15,8 +15,8 @@ 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_s3::{HeadObjectError, HeadObjectRequest, PutObjectRequest, S3Client, S3}; +use rusoto_core::{request::BufferedHttpResponse, Region, RusotoError}; +use rusoto_s3::{HeadObjectRequest, PutObjectRequest, S3Client, S3}; use serde::{Deserialize, Serialize}; use std::{fs, path::PathBuf}; use tokio::runtime::Handle; @@ -209,7 +209,11 @@ impl BlockHandler for S3BlockWriter { let result = runtime.block_on(self.s3_client.head_object(req)); match result { Ok(_) => OperationResult::Ok(true), - Err(RusotoError::Service(HeadObjectError::NoSuchKey(_))) => { + // Happens when the object doesn't exist, see + // https://docs.aws.amazon.com/cli/latest/reference/s3api/head-object.html + Err(RusotoError::Unknown(BufferedHttpResponse { status, .. })) + if status.as_u16() == 404 => + { OperationResult::Ok(false) } Err(e) => {