Skip to content

Commit

Permalink
Ensure restored spaces that have been deleted by the duracloud user c… (
Browse files Browse the repository at this point in the history
#34)

* Ensure restored spaces that have been deleted by the duracloud user can be transition to expired state.
  • Loading branch information
dbernstein committed Mar 1, 2024
1 parent 258e487 commit deb8c5c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -488,27 +488,38 @@ public void finalizeRestores() {
bridgeConfig.getDuracloudPassword());
try {
String spaceId = destination.getSpaceId();
Iterator<String> it = store.getSpaceContents(spaceId);
if (!it.hasNext()) { // if space is empty
// Call DuraCloud to remove space
log.info("Deleting expired restoration space: " + spaceId +
" at host: " + destination.getHost());
store.deleteSpace(spaceId);
boolean spaceExists = store.spaceExists(spaceId);

if (spaceExists) {
Iterator<String> it = store.getSpaceContents(spaceId);
if (!it.hasNext()) { // if space is empty
// Call DuraCloud to remove space
log.info("Deleting expired restoration space: " + spaceId +
" at host: " + destination.getHost());
store.deleteSpace(spaceId);
spaceExists = false;
}
}

if (!spaceExists) {
// Update restore status
validateAndSet(restoration,
RestoreStatus.RESTORATION_EXPIRED,
"Restoration expired");
RestoreStatus.RESTORATION_EXPIRED,
"Restoration expired");
restoration = save(restoration);
log.info("Transition of restore " +
restoration.getRestorationId() +
" to expired state completed successfully");
restoration.getRestorationId() +
" to expired state completed successfully");

// Add history event
String history =
"[{'" + RESTORE_ACTION_TITLE + "':'" + RESTORE_ACTION_EXPIRED + "'}," +
"{'" + RESTORE_ID_TITLE + "':'" + restoration.getRestorationId() + "'}]";
"[{'" + RESTORE_ACTION_TITLE + "':'" + RESTORE_ACTION_EXPIRED + "'}," +
"{'" + RESTORE_ID_TITLE + "':'" + restoration.getRestorationId() + "'}]";
snapshotManager.updateHistory(restoration.getSnapshot(), history);

} else {
log.info("Space {} is not empty. Space will be removed and restoration {} transition to " +
"expired state when space is empty.", spaceId, restoration);
}
} catch (Exception e) {
log.error("Failed to transition restore " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ public void testFinalizeRestores() throws Exception {

expect(destination.getSpaceId()).andReturn(spaceId);
expect(destination.getHost()).andReturn(host);
expect(contentStore.spaceExists(spaceId)).andReturn(true);
expect(contentStore.getSpaceContents(spaceId))
.andReturn(Collections.<String>emptyList().iterator());

Expand Down

0 comments on commit deb8c5c

Please sign in to comment.