Skip to content

Commit

Permalink
#LUC070-147 Add back TSM deletes along with retries
Browse files Browse the repository at this point in the history
1) Updated TivoliStorageManager.delete so that all the removed delete code is reverted along with new code to retry the number times and sleep the length configured in datavault.properties.
2) Updated TivoliStorageManagerTest so that the delete TSM instance is configured with custom retry / length values.
  • Loading branch information
dspeed2 committed Dec 10, 2024
1 parent da9ed04 commit 909a246
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,16 +208,26 @@ public Verify.Method getVerifyMethod() {
public void delete(String depositId, File working, Progress progress, String optFilePath) throws Exception {
Path depositDirectoryPath = getDepositDirectoryPath(depositId);
Path tsmFilePath = depositDirectoryPath.resolve(working.getName());
log.info("TSM Delete [{}] skipping",tsmFilePath);
//ProcessHelper.ProcessInfo info = getProcessInfo("tsmDelete",
// "dsmc", "delete", "archive", tsmFilePath.toString(), "-noprompt", "-optfile=" + optFilePath);
//if (info.wasFailure()) {
// String errMessage = String.format("Delete of [%s] failed.", tsmFilePath);
// logProcessOutput(info, errMessage);
// throw new Exception(errMessage);
//} else {
// log.info("Delete of [{}] was Successful.", tsmFilePath);
//}
log.info("TSM Delete [{}] ",tsmFilePath);

boolean deleted = false;
for (int r = 0; r < maxRetries && !deleted; r++) {
ProcessHelper.ProcessInfo info = getProcessInfo("tsmDelete",
"dsmc", "delete", "archive", tsmFilePath.toString(), "-noprompt", "-optfile=" + optFilePath);
String attemptCtx = String.format("attempt[%s/%s]", r+1, maxRetries);
if (info.wasFailure()) {
boolean lastAttempt = r == (maxRetries -1);
String errMessage = String.format("Delete of [%s] failed using location[%s] %s", tsmFilePath, optFilePath, attemptCtx);
logProcessOutput(info, errMessage);
if (lastAttempt) {
throw new Exception(errMessage);
}
log.info("{} Retrying in {} mins", errMessage, retryTimeSeconds);
TimeUnit.SECONDS.sleep(retryTimeSeconds);
} else {
log.info("Delete of [{}] was Successful.", tsmFilePath);
}
}
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,12 @@ void setup() throws IOException {
Map<String, String> props = new HashMap<>();
props.put(PropNames.TEMP_DIR, tsmTemp.toString());
props.put(PropNames.OPTIONS_DIR, "/tmp/opt");
props.put(PropNames.TSM_MAX_RETRIES, "5");
props.put(PropNames.TSM_RETRY_TIME, "1");
tsm = Mockito.spy(new TivoliStorageManager("testTSM", props));
}

// Removed as TSM deletes can never succeed for TSM since the move to write once tapes
// resulted in us not deleting them
/*@Test
@Test
void testDeleteSucceeds() throws Exception {

File fileToDelete = Files.createTempFile("test",".txt").toFile();
Expand All @@ -333,11 +333,9 @@ void testDeleteSucceeds() throws Exception {

//Check that the local file has not been deleted. We are trying to delete file on TSM ONLY
assertThat(fileToDelete).exists();
}*/
}

// Removed as TSM deletes can never fail for TSM since the move to write once tapes
// resulted in us not deleting them
/*@Test
@Test
void testDeleteFails() throws Exception {

File fileToDelete = Files.createTempFile("test",".txt").toFile();
Expand All @@ -356,7 +354,7 @@ void testDeleteFails() throws Exception {
tsm.delete("testDepositId", fileToDelete, progress, "specificLocation");
});
String expectedTsmFile = tsmTemp.resolve("testDepositId").resolve(fileToDelete.getName()).toString();
String expectedErrorMessage = String.format("Delete of [%s] failed.",expectedTsmFile);
String expectedErrorMessage = String.format("Delete of [%s] failed using location[specificLocation] attempt[5/5]",expectedTsmFile);
assertThat(ex).hasMessage(expectedErrorMessage);

assertThat(argDesc.getValue()).isEqualTo("tsmDelete");
Expand All @@ -365,7 +363,7 @@ void testDeleteFails() throws Exception {

//Check that the local file has not been deleted. We are trying to delete file on TSM ONLY
assertThat(fileToDelete).exists();
}*/
}

}

Expand Down

0 comments on commit 909a246

Please sign in to comment.