From commits-return-71681-archive-asf-public=cust-asf.ponee.io@cloudstack.apache.org Tue Feb 6 19:51:54 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id 2912C18067C for ; Tue, 6 Feb 2018 19:51:54 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 1951E160C37; Tue, 6 Feb 2018 18:51:54 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 66494160C5C for ; Tue, 6 Feb 2018 19:51:53 +0100 (CET) Received: (qmail 47517 invoked by uid 500); 6 Feb 2018 18:51:52 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 47273 invoked by uid 99); 6 Feb 2018 18:51:52 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Feb 2018 18:51:52 +0000 From: GitBox To: commits@cloudstack.apache.org Subject: [GitHub] DaanHoogland commented on a change in pull request #2447: Add retry logic to direct download and checksum, also refactoring Message-ID: <151794311171.16257.3923946383434699810.gitbox@gitbox.apache.org> DaanHoogland commented on a change in pull request #2447: Add retry logic to direct download and checksum, also refactoring URL: https://github.com/apache/cloudstack/pull/2447#discussion_r166404453 ########## File path: server/src/org/apache/cloudstack/direct/download/DirectDownloadManagerImpl.java ########## @@ -167,10 +210,22 @@ public void downloadTemplate(long templateId, long poolId, long hostId) { DownloadProtocol protocol = getProtocolFromUrl(url); DirectDownloadCommand cmd = getDirectDownloadCommandFromProtocol(protocol, url, templateId, to, checksum, headers); - Answer answer = agentManager.easySend(hostId, cmd); - if (answer == null || !answer.getResult()) { - throw new CloudRuntimeException("Host " + hostId + " could not download template " + - templateId + " on pool " + poolId); + + boolean downloaded = false; + int retry = 3; + Long[] hostsToRetry = getHostsToRetryOn(host.getClusterId(), host.getDataCenterId(), host.getHypervisorType(), hostId); + int hostIndex = 0; + Answer answer = null; + Long hostToSendDownloadCmd = hostsToRetry[hostIndex]; + while (!downloaded && retry > 0) { + s_logger.debug("Sending Direct download command to host " + hostToSendDownloadCmd); + answer = agentManager.easySend(hostToSendDownloadCmd, cmd); + downloaded = answer != null && answer.getResult(); + hostToSendDownloadCmd = hostsToRetry[(hostIndex + 1) % hostsToRetry.length]; Review comment: so we try three times on possibly three different hosts? are those the ones that the deployments are on (local storage used)? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org With regards, Apache Git Services