mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Improve template download error message (#8029)
This commit is contained in:
parent
a20ab40b67
commit
c0128e2f9a
@ -42,6 +42,7 @@ import javax.inject.Inject;
|
|||||||
import javax.naming.ConfigurationException;
|
import javax.naming.ConfigurationException;
|
||||||
|
|
||||||
import com.cloud.exception.InvalidParameterValueException;
|
import com.cloud.exception.InvalidParameterValueException;
|
||||||
|
import com.cloud.user.Account;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import org.apache.cloudstack.agent.directdownload.DirectDownloadAnswer;
|
import org.apache.cloudstack.agent.directdownload.DirectDownloadAnswer;
|
||||||
import org.apache.cloudstack.agent.directdownload.DirectDownloadCommand;
|
import org.apache.cloudstack.agent.directdownload.DirectDownloadCommand;
|
||||||
@ -329,6 +330,8 @@ public class DirectDownloadManagerImpl extends ManagerBase implements DirectDown
|
|||||||
Long[] hostsToRetry = getHostsToRetryOn(host, storagePoolVO);
|
Long[] hostsToRetry = getHostsToRetryOn(host, storagePoolVO);
|
||||||
int hostIndex = 0;
|
int hostIndex = 0;
|
||||||
Answer answer = null;
|
Answer answer = null;
|
||||||
|
String answerDetails = "";
|
||||||
|
String errorDetails = "";
|
||||||
Long hostToSendDownloadCmd = hostsToRetry[hostIndex];
|
Long hostToSendDownloadCmd = hostsToRetry[hostIndex];
|
||||||
boolean continueRetrying = true;
|
boolean continueRetrying = true;
|
||||||
while (!downloaded && retry > 0 && continueRetrying) {
|
while (!downloaded && retry > 0 && continueRetrying) {
|
||||||
@ -349,6 +352,7 @@ public class DirectDownloadManagerImpl extends ManagerBase implements DirectDown
|
|||||||
if (answer != null) {
|
if (answer != null) {
|
||||||
DirectDownloadAnswer ans = (DirectDownloadAnswer)answer;
|
DirectDownloadAnswer ans = (DirectDownloadAnswer)answer;
|
||||||
downloaded = answer.getResult();
|
downloaded = answer.getResult();
|
||||||
|
answerDetails = answer.getDetails();
|
||||||
continueRetrying = ans.isRetryOnOtherHosts();
|
continueRetrying = ans.isRetryOnOtherHosts();
|
||||||
}
|
}
|
||||||
hostToSendDownloadCmd = hostsToRetry[(hostIndex + 1) % hostsToRetry.length];
|
hostToSendDownloadCmd = hostsToRetry[(hostIndex + 1) % hostsToRetry.length];
|
||||||
@ -362,7 +366,13 @@ public class DirectDownloadManagerImpl extends ManagerBase implements DirectDown
|
|||||||
}
|
}
|
||||||
if (!downloaded) {
|
if (!downloaded) {
|
||||||
logUsageEvent(template, poolId);
|
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;
|
return answer;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user