-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[Veeam] Check for failures in the restore process #7224
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -345,7 +345,7 @@ private boolean checkTaskStatus(final HttpResponse response) throws IOException | |
String type = pair.second(); | ||
String path = url.replace(apiURI.toString(), ""); | ||
if (type.equals("RestoreSession")) { | ||
return checkIfRestoreSessionFinished(type, path); | ||
checkIfRestoreSessionFinished(type, path); | ||
} | ||
} | ||
return true; | ||
|
@@ -361,17 +361,29 @@ private boolean checkTaskStatus(final HttpResponse response) throws IOException | |
return false; | ||
} | ||
|
||
protected boolean checkIfRestoreSessionFinished(String type, String path) throws IOException { | ||
for (int j = 0; j < this.restoreTimeout; j++) { | ||
|
||
/** | ||
* Checks the status of the restore session. Checked states are "Success" and "Failure".<br/> | ||
* There is also a timeout defined in the global configuration, backup.plugin.veeam.restore.timeout,<br/> | ||
* that is used to wait for the restore to complete before throwing a {@link CloudRuntimeException}. | ||
*/ | ||
protected void checkIfRestoreSessionFinished(String type, String path) throws IOException { | ||
for (int j = 0; j < restoreTimeout; j++) { | ||
HttpResponse relatedResponse = get(path); | ||
RestoreSession session = parseRestoreSessionResponse(relatedResponse); | ||
if (session.getResult().equals("Success")) { | ||
return true; | ||
return; | ||
} | ||
|
||
if (session.getResult().equalsIgnoreCase("Failed")) { | ||
String sessionUid = session.getUid(); | ||
LOG.error(String.format("Failed to restore backup [%s] of VM [%s] due to [%s].", | ||
sessionUid, session.getVmDisplayName(), | ||
getRestoreVmErrorDescription(StringUtils.substringAfterLast(sessionUid, ":")))); | ||
throw new CloudRuntimeException(String.format("Restore job [%s] failed.", sessionUid)); | ||
} | ||
LOG.debug(String.format("Waiting %s seconds, out of a total of %s seconds, for the restore backup process to finish.", j, restoreTimeout)); | ||
|
||
try { | ||
Thread.sleep(1000); | ||
} catch (InterruptedException ignored) { | ||
|
@@ -930,6 +942,29 @@ public Pair<Boolean, String> restoreVMToDifferentLocation(String restorePointId, | |
return new Pair<>(result.first(), restoreLocation); | ||
} | ||
|
||
/** | ||
* Tries to retrieve the error's description of the Veeam restore task that resulted in an error. | ||
* @param uid Session uid in Veeam of the restore process; | ||
* @return the description found in Veeam about the cause of error in the restore process. | ||
*/ | ||
protected String getRestoreVmErrorDescription(String uid) { | ||
LOG.debug(String.format("Trying to find the cause of error in the restore process [%s].", uid)); | ||
List<String> cmds = Arrays.asList( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can this be replaced by REST api ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can get the description via powershell command
the description is empty (probably because the task is done without any issue). checked rest api reference, there is no description in the respose of restoreSession. however, the task has I wonder if we can use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll try to take a look at this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good , thanks @JoaoJandre |
||
String.format("$restoreUid = '%s'", uid), | ||
"$restore = Get-VBRRestoreSession -Id $restoreUid", | ||
"if ($restore) {", | ||
"Write-Output $restore.Description", | ||
"} else {", | ||
"Write-Output 'Cannot find restore session with provided uid $restoreUid'", | ||
"}" | ||
); | ||
Pair<Boolean, String> result = executePowerShellCommands(cmds); | ||
if (result != null && result.first()) { | ||
return result.second(); | ||
} | ||
return String.format("Failed to get the description of the failed restore session [%s]. Please contact an administrator.", uid); | ||
} | ||
|
||
private boolean isLegacyServer() { | ||
return this.veeamServerVersion != null && (this.veeamServerVersion > 0 && this.veeamServerVersion < 11); | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.