Skip to content

Commit c3aeba1

Browse files
Merge remote-tracking branch 'origin/4.18'
2 parents e333f27 + c0128e2 commit c3aeba1

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

server/src/main/java/org/apache/cloudstack/direct/download/DirectDownloadManagerImpl.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import javax.naming.ConfigurationException;
4343

4444
import com.cloud.exception.InvalidParameterValueException;
45+
import com.cloud.user.Account;
4546
import com.cloud.utils.Pair;
4647
import org.apache.cloudstack.agent.directdownload.DirectDownloadAnswer;
4748
import org.apache.cloudstack.agent.directdownload.DirectDownloadCommand;
@@ -329,6 +330,8 @@ private Answer sendDirectDownloadCommand(DirectDownloadCommand cmd, VMTemplateVO
329330
Long[] hostsToRetry = getHostsToRetryOn(host, storagePoolVO);
330331
int hostIndex = 0;
331332
Answer answer = null;
333+
String answerDetails = "";
334+
String errorDetails = "";
332335
Long hostToSendDownloadCmd = hostsToRetry[hostIndex];
333336
boolean continueRetrying = true;
334337
while (!downloaded && retry > 0 && continueRetrying) {
@@ -349,6 +352,7 @@ private Answer sendDirectDownloadCommand(DirectDownloadCommand cmd, VMTemplateVO
349352
if (answer != null) {
350353
DirectDownloadAnswer ans = (DirectDownloadAnswer)answer;
351354
downloaded = answer.getResult();
355+
answerDetails = answer.getDetails();
352356
continueRetrying = ans.isRetryOnOtherHosts();
353357
}
354358
hostToSendDownloadCmd = hostsToRetry[(hostIndex + 1) % hostsToRetry.length];
@@ -362,7 +366,13 @@ private Answer sendDirectDownloadCommand(DirectDownloadCommand cmd, VMTemplateVO
362366
}
363367
if (!downloaded) {
364368
logUsageEvent(template, poolId);
365-
throw new CloudRuntimeException("Template " + template.getId() + " could not be downloaded on pool " + poolId + ", failing after trying on several hosts");
369+
if (!answerDetails.isEmpty()){
370+
Account caller = CallContext.current().getCallingAccount();
371+
if (caller != null && caller.getType() == Account.Type.ADMIN){
372+
errorDetails = String.format(" Details: %s", answerDetails);
373+
}
374+
}
375+
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));
366376
}
367377
return answer;
368378
}

0 commit comments

Comments
 (0)