Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sentry cleanup in s3uploader #2150

Merged
merged 1 commit into from
Oct 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.io.File;
import java.nio.file.FileSystem;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -110,17 +111,17 @@ protected void uploadSingle(int sequence, Path file) throws Exception {
hostname
);

long fileSizeBytes = Files.size(file);
LOG.info(
"{} Uploading {} to {}/{} (size {})",
logIdentifier,
file,
bucketName,
key,
fileSizeBytes
);

try {
long fileSizeBytes = Files.size(file);
LOG.info(
"{} Uploading {} to {}/{} (size {})",
logIdentifier,
file,
bucketName,
key,
fileSizeBytes
);

ObjectMetadata objectMetadata = new ObjectMetadata();

UploaderFileAttributes fileAttributes = getFileAttributes(file);
Expand Down Expand Up @@ -212,6 +213,14 @@ protected void uploadSingle(int sequence, Path file) throws Exception {
s3Client.putObject(putObjectRequest);
}
} catch (AmazonS3Exception se) {
if (se.getMessage().contains("does not exist in our records")) {
LOG.warn(
"Upload cannot succeed with S3 key that does not exit in AWS, marking {} as complete",
uploadMetadata
);
return true;
}

LOG.warn(
"{} Couldn't upload {} due to {} - {}",
logIdentifier,
Expand All @@ -221,6 +230,12 @@ protected void uploadSingle(int sequence, Path file) throws Exception {
se
);
throw se;
} catch (NoSuchFileException nsfe) {
LOG.warn(
"File {} no longer exists, marking upload as complete",
nsfe.getFile()
);
return true;
} catch (Exception e) {
LOG.warn("Exception uploading {}", file, e);
throw e;
Expand Down