Skip to content

Commit

Permalink
move Kudu delays to configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
giuliov committed Mar 19, 2022
1 parent d493ade commit 804da9c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
14 changes: 5 additions & 9 deletions src/aggregator-cli/Kudu/KuduApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,12 @@ internal async Task<string> 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);
Expand Down

0 comments on commit 804da9c

Please sign in to comment.