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
…an be transition to expired state.
  • Loading branch information
dbernstein committed Mar 1, 2024
1 parent 258e487 commit 66316b1
Showing 1 changed file with 26 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -488,28 +488,42 @@ 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);
boolean spaceEmpty = false;

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

if (!spaceExists || spaceEmpty){
// 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 " +
restoration.getRestorationId() +
Expand Down

0 comments on commit 66316b1

Please sign in to comment.