From 804da9c2940b9ffba445809d3d4a34f066859016 Mon Sep 17 00:00:00 2001 From: Giulio Vian Date: Sat, 19 Mar 2022 12:20:07 +0000 Subject: [PATCH] move Kudu delays to configuration --- .github/workflows/build-and-deploy.yml | 2 ++ src/aggregator-cli/Kudu/KuduApi.cs | 14 +++++--------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index fe6b824..52ca35d 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -23,6 +23,8 @@ jobs: CONFIGURATION: Release SONAR_ORG: 'tfsaggregator' SONAR_PROJECTKEY: 'tfsaggregator_aggregator-cli' + # list of TimeSpan controlling reading app logs from Kudu while running Integration tests + AGGREGATOR_KUDU_LOGRETRIEVE_ATTEMPTS: '0:0:30 0:1:00 0:1:30 0:2:00 0:3:00' outputs: dockerTag: 'v${{ steps.gitversion.outputs.fullSemVer }}' releaseTag: ${{ steps.get_git_tag.outputs.tag_name }} diff --git a/src/aggregator-cli/Kudu/KuduApi.cs b/src/aggregator-cli/Kudu/KuduApi.cs index c9a6eaa..d0eecff 100644 --- a/src/aggregator-cli/Kudu/KuduApi.cs +++ b/src/aggregator-cli/Kudu/KuduApi.cs @@ -112,16 +112,12 @@ internal async Task ReadApplicationLogAsync(string functionName, int log using var client = new HttpClient(); ListingEntry[] listingResult = null; - TimeSpan[] delay = { - new TimeSpan(0, 0, 5), - new TimeSpan(0, 0, 12), - new TimeSpan(0, 0, 25), - new TimeSpan(0, 0, 55), - new TimeSpan(0, 1, 30), - }; - for (int attempt = 0; attempt < delay.Length; attempt++) + string delayList = Environment.GetEnvironmentVariable("AGGREGATOR_KUDU_LOGRETRIEVE_ATTEMPTS") + ?? "0:0:5 0:0:12 0:0:25 0:0:55 0:1:30"; + var delay = delayList.Split(' ').Select(s => TimeSpan.Parse(s)).ToList(); + for (int attempt = 0; attempt < delay.Count; attempt++) { - logger.WriteVerbose($"Listing attempt #{attempt + 1})"); + logger.WriteVerbose($"Attempt #{attempt + 1} to retrieve listing"); using var listingRequest = await GetRequestAsync(HttpMethod.Get, $"{FunctionLogPath}/{functionName}/", cancellationToken); var listingResponse = await client.SendAsync(listingRequest, cancellationToken); var listingStream = await listingResponse.Content.ReadAsStreamAsync(cancellationToken);