From 3ae0245dda5fc7a1532ee40fd17ca828983449dc Mon Sep 17 00:00:00 2001 From: Adam Jordens Date: Mon, 21 Mar 2016 22:38:48 -0700 Subject: [PATCH] It's possible that an item could be removed mid-refresh cycle - The refresh will (currently) fail and be re-picked up next iteration (no harm no foul really beyond an exception) - This change has the refresh succeeding by removing/skipping the deleted item --- .../spinnaker/front50/model/S3Support.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/front50-s3/src/main/java/com/netflix/spinnaker/front50/model/S3Support.java b/front50-s3/src/main/java/com/netflix/spinnaker/front50/model/S3Support.java index 7f35b3f54..b61137fad 100644 --- a/front50-s3/src/main/java/com/netflix/spinnaker/front50/model/S3Support.java +++ b/front50-s3/src/main/java/com/netflix/spinnaker/front50/model/S3Support.java @@ -213,8 +213,19 @@ protected Set fetchAllItems(Set existingItems) { .buffer(10) .flatMap(ids -> Observable .from(ids) - .flatMap(s3ObjectSummary -> - Observable.just(amazonS3.getObject(s3ObjectSummary.getBucketName(), s3ObjectSummary.getKey())) + .flatMap(s3ObjectSummary -> { + try { + return Observable.just(amazonS3.getObject(s3ObjectSummary.getBucketName(), s3ObjectSummary.getKey())); + } catch (AmazonS3Exception e) { + if (e.getStatusCode() == 404) { + // an item has been removed between the time that object summaries were fetched and now + existingItemsByName.remove(extractItemName(s3ObjectSummary)); + return Observable.empty(); + } + + throw e; + } + } ) .subscribeOn(scheduler) ) @@ -292,5 +303,6 @@ private String extractItemName(S3ObjectSummary s3ObjectSummary) { } abstract Class getSerializedClass(); + abstract String getMetadataFilename(); }