Skip to content

Commit 918b472

Browse files
authored
set timeout (#2589)
1 parent bec8995 commit 918b472

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/BuildScriptGenerator/DotNetCore/VersionProviders/DotNetCoreSdkStorageVersionProvider.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public void GetVersionInfo()
5858
if (this.versionMap == null)
5959
{
6060
var httpClient = this.HttpClientFactory.CreateClient("general");
61+
httpClient.Timeout = TimeSpan.FromSeconds(10);
6162
var sdkStorageBaseUrl = this.GetPlatformBinariesStorageBaseUrl();
6263
XDocument xdoc = null;
6364

src/BuildScriptGenerator/PlatformInstallerBase.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ protected string GetInstallerScriptSnippet(
159159
snippet.AppendLine("PLATFORM_BINARY_DOWNLOAD_START=$SECONDS")
160160
.AppendLine("downloaded=1")
161161
.AppendLine($"if [ \"$DEBIAN_FLAVOR\" == \"{OsTypes.DebianStretch}\" ]; then")
162-
.AppendLine($"curl -D headers.txt -SL \"{sdkStorageBaseUrl}/{platformName}/{platformName}-{version}.tar.gz\" --output {tarFile} >/dev/null 2>&1 || downloaded=0")
162+
.AppendLine($"curl --connect-timeout 10 -D headers.txt -SL \"{sdkStorageBaseUrl}/{platformName}/{platformName}-{version}.tar.gz\" --output {tarFile} >/dev/null 2>&1 || downloaded=0")
163163
.AppendLine("else")
164-
.AppendLine($"curl -D headers.txt -SL \"{sdkStorageBaseUrl}/{platformName}/{platformName}-$DEBIAN_FLAVOR-{version}.tar.gz\" --output {tarFile} >/dev/null 2>&1 || downloaded=0")
164+
.AppendLine($"curl --connect-timeout 10 -D headers.txt -SL \"{sdkStorageBaseUrl}/{platformName}/{platformName}-$DEBIAN_FLAVOR-{version}.tar.gz\" --output {tarFile} >/dev/null 2>&1 || downloaded=0")
165165
.AppendLine("fi")
166166
.AppendLine($"if [ $downloaded -eq 0 ]; then")
167167
.AppendLine($" if [ -z \"{sdkStorageBackupBaseUrl}\" ]; then")
@@ -170,9 +170,9 @@ protected string GetInstallerScriptSnippet(
170170
.AppendLine(" fi")
171171
.AppendLine(" echo \"Download using primary SDK storage URL failed, trying backup storage URL...\"")
172172
.AppendLine($" if [ \"$DEBIAN_FLAVOR\" == \"{OsTypes.DebianStretch}\" ]; then")
173-
.AppendLine($" curl -D headers.txt -SL \"{sdkStorageBackupBaseUrl}/{platformName}/{platformName}-{version}.tar.gz\" --output {tarFile} >/dev/null 2>&1")
173+
.AppendLine($" curl --connect-timeout 10 -D headers.txt -SL \"{sdkStorageBackupBaseUrl}/{platformName}/{platformName}-{version}.tar.gz\" --output {tarFile} >/dev/null 2>&1")
174174
.AppendLine(" else")
175-
.AppendLine($" curl -D headers.txt -SL \"{sdkStorageBackupBaseUrl}/{platformName}/{platformName}-$DEBIAN_FLAVOR-{version}.tar.gz\" --output {tarFile} >/dev/null 2>&1")
175+
.AppendLine($" curl --connect-timeout 10 -D headers.txt -SL \"{sdkStorageBackupBaseUrl}/{platformName}/{platformName}-$DEBIAN_FLAVOR-{version}.tar.gz\" --output {tarFile} >/dev/null 2>&1")
176176
.AppendLine(" fi")
177177
.AppendLine("fi")
178178
.AppendLine("PLATFORM_BINARY_DOWNLOAD_ELAPSED_TIME=$(($SECONDS - $PLATFORM_BINARY_DOWNLOAD_START))")

src/BuildScriptGenerator/SdkStorageVersionProviderBase.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ protected PlatformVersionInfo GetAvailableVersionsFromStorage(string platformNam
5050
{
5151
this.logger.LogDebug("Getting list of available versions for platform {platformName}.", platformName);
5252
var httpClient = this.HttpClientFactory.CreateClient("general");
53+
httpClient.Timeout = TimeSpan.FromSeconds(10);
5354
var sdkStorageBaseUrl = this.GetPlatformBinariesStorageBaseUrl();
5455
XDocument xdoc = null;
5556

@@ -115,6 +116,7 @@ protected PlatformVersionInfo GetAvailableVersionsFromStorage(string platformNam
115116
protected string GetDefaultVersion(string platformName, string sdkStorageBaseUrl)
116117
{
117118
var httpClient = this.HttpClientFactory.CreateClient("general");
119+
httpClient.Timeout = TimeSpan.FromSeconds(10);
118120

119121
var defaultFile = string.IsNullOrEmpty(this.commonOptions.DebianFlavor)
120122
|| string.Equals(this.commonOptions.DebianFlavor, OsTypes.DebianStretch, StringComparison.OrdinalIgnoreCase)

0 commit comments

Comments
 (0)