Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/4.18'
Browse files Browse the repository at this point in the history
  • Loading branch information
rohityadavcloud committed Oct 9, 2023
2 parents e333f27 + c0128e2 commit c3aeba1
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import javax.naming.ConfigurationException;

import com.cloud.exception.InvalidParameterValueException;
import com.cloud.user.Account;
import com.cloud.utils.Pair;
import org.apache.cloudstack.agent.directdownload.DirectDownloadAnswer;
import org.apache.cloudstack.agent.directdownload.DirectDownloadCommand;
Expand Down Expand Up @@ -329,6 +330,8 @@ private Answer sendDirectDownloadCommand(DirectDownloadCommand cmd, VMTemplateVO
Long[] hostsToRetry = getHostsToRetryOn(host, storagePoolVO);
int hostIndex = 0;
Answer answer = null;
String answerDetails = "";
String errorDetails = "";
Long hostToSendDownloadCmd = hostsToRetry[hostIndex];
boolean continueRetrying = true;
while (!downloaded && retry > 0 && continueRetrying) {
Expand All @@ -349,6 +352,7 @@ private Answer sendDirectDownloadCommand(DirectDownloadCommand cmd, VMTemplateVO
if (answer != null) {
DirectDownloadAnswer ans = (DirectDownloadAnswer)answer;
downloaded = answer.getResult();
answerDetails = answer.getDetails();
continueRetrying = ans.isRetryOnOtherHosts();
}
hostToSendDownloadCmd = hostsToRetry[(hostIndex + 1) % hostsToRetry.length];
Expand All @@ -362,7 +366,13 @@ private Answer sendDirectDownloadCommand(DirectDownloadCommand cmd, VMTemplateVO
}
if (!downloaded) {
logUsageEvent(template, poolId);
throw new CloudRuntimeException("Template " + template.getId() + " could not be downloaded on pool " + poolId + ", failing after trying on several hosts");
if (!answerDetails.isEmpty()){
Account caller = CallContext.current().getCallingAccount();
if (caller != null && caller.getType() == Account.Type.ADMIN){
errorDetails = String.format(" Details: %s", answerDetails);
}
}
throw new CloudRuntimeException(String.format("Template %d could not be downloaded on pool %d, failing after trying on several hosts%s", template.getId(), poolId, errorDetails));
}
return answer;
}
Expand Down

0 comments on commit c3aeba1

Please sign in to comment.