DaanHoogland commented on code in PR #7224:
URL: https://github.com/apache/cloudstack/pull/7224#discussion_r1106879989
##########
plugins/backup/veeam/src/main/java/org/apache/cloudstack/backup/veeam/VeeamClient.java:
##########
@@ -301,7 +301,26 @@ 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);
+ for (int j = 0; j < restoreTimeout; j++) {
+ HttpResponse relatedResponse = get(path);
+ RestoreSession session =
parseRestoreSessionResponse(relatedResponse);
+ if (session.getResult().equals("Success")) {
+ return true;
+ }
+ 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 backup process to finish.", j,
restoreTimeout));
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ignored) {
+ }
+ }
+ throw new CloudRuntimeException("Related job type:
" + type + " was not successful");
Review Comment:
why not keep a separate method? This adds to the complexity of this method
and `checkIfRestoreSessionFinished` was a clear name.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]