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

Ensure restored spaces that have been deleted by the duracloud user c… #34

Merged
Show file tree
Hide file tree
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 @@ -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
Loading