From: Joel Hendrix Date: Thu, 26 May 2016 17:01:38 +0000 (-0700) Subject: Add retry logic when downloading the CLI from Azure blob storage. X-Git-Tag: accepted/tizen/base/20180629.140029~4531^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2fab93aebd5365ea3716a4a4d3b87d6047698e09;p=platform%2Fupstream%2Fcoreclr.git Add retry logic when downloading the CLI from Azure blob storage. Downloading from Azure can transiently fail for a number of reasons. Add some retry logic when downloading to avoid transient failures. For *nix variants add a retry value when using curl (wget retries by default). --- diff --git a/init-tools.cmd b/init-tools.cmd index d15c641..669e6a0 100644 --- a/init-tools.cmd +++ b/init-tools.cmd @@ -48,7 +48,7 @@ set DOTNET_ZIP_NAME=dotnet-dev-win-x64.%DOTNET_VERSION%.zip set DOTNET_REMOTE_PATH=https://dotnetcli.blob.core.windows.net/dotnet/beta/Binaries/%DOTNET_VERSION%/%DOTNET_ZIP_NAME% set DOTNET_LOCAL_PATH=%DOTNET_PATH%%DOTNET_ZIP_NAME% echo Installing '%DOTNET_REMOTE_PATH%' to '%DOTNET_LOCAL_PATH%' >> "%INIT_TOOLS_LOG%" -powershell -NoProfile -ExecutionPolicy unrestricted -Command "(New-Object Net.WebClient).DownloadFile('%DOTNET_REMOTE_PATH%', '%DOTNET_LOCAL_PATH%'); Add-Type -Assembly 'System.IO.Compression.FileSystem' -ErrorVariable AddTypeErrors; if ($AddTypeErrors.Count -eq 0) { [System.IO.Compression.ZipFile]::ExtractToDirectory('%DOTNET_LOCAL_PATH%', '%DOTNET_PATH%') } else { (New-Object -com shell.application).namespace('%DOTNET_PATH%').CopyHere((new-object -com shell.application).namespace('%DOTNET_LOCAL_PATH%').Items(),16) }" >> "%INIT_TOOLS_LOG%" +powershell -NoProfile -ExecutionPolicy unrestricted -Command "$retryCount = 0; $success = $false; do { try { (New-Object Net.WebClient).DownloadFile('%DOTNET_REMOTE_PATH%', '%DOTNET_LOCAL_PATH%'); $success = $true; } catch { if ($retryCount -ge 6) { throw; } else { $retryCount++; Start-Sleep -Seconds (5 * $retryCount); } } } while ($success -eq $false); Add-Type -Assembly 'System.IO.Compression.FileSystem' -ErrorVariable AddTypeErrors; if ($AddTypeErrors.Count -eq 0) { [System.IO.Compression.ZipFile]::ExtractToDirectory('%DOTNET_LOCAL_PATH%', '%DOTNET_PATH%') } else { (New-Object -com shell.application).namespace('%DOTNET_PATH%').CopyHere((new-object -com shell.application).namespace('%DOTNET_LOCAL_PATH%').Items(),16) }" >> "%INIT_TOOLS_LOG%" if NOT exist "%DOTNET_LOCAL_PATH%" ( echo ERROR: Could not install dotnet cli correctly. See '%INIT_TOOLS_LOG%' for more details. set TOOLS_INIT_RETURN_CODE=1 diff --git a/init-tools.sh b/init-tools.sh index 759a2ec..45009d4 100755 --- a/init-tools.sh +++ b/init-tools.sh @@ -96,8 +96,8 @@ if [ ! -e $__PROJECT_JSON_FILE ]; then wget -q -O $__DOTNET_PATH/dotnet.tar $__CLIDownloadURL echo "wget -q -O $__DOTNET_PATH/dotnet.tar $__CLIDownloadURL" else - curl -sSL --create-dirs -o $__DOTNET_PATH/dotnet.tar $__CLIDownloadURL - echo "curl -sSL --create-dirs -o $__DOTNET_PATH/dotnet.tar $__CLIDownloadURL" + curl --retry 10 -sSL --create-dirs -o $__DOTNET_PATH/dotnet.tar $__CLIDownloadURL + echo "curl --retry 10 -sSL --create-dirs -o $__DOTNET_PATH/dotnet.tar $__CLIDownloadURL" fi cd $__DOTNET_PATH tar -xf $__DOTNET_PATH/dotnet.tar