Skip to content

Commit

Permalink
more retries and logging
Browse files Browse the repository at this point in the history
  • Loading branch information
giuliov committed Dec 29, 2021
1 parent 91c153b commit 10cc9a7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/aggregator-cli/Kudu/KuduApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ internal async Task<string> ReadApplicationLogAsync(string functionName, int log
{
ListingEntry[] listingResult = null;

for (int attempt = 1; attempt <= 3; attempt++)
int[] delay = { 300, 700, 1000, 1200, 1500, 2000 };
for (int attempt = 0; attempt < delay.Length; attempt++)
{
using (var listingRequest = await GetRequestAsync(HttpMethod.Get, $"{FunctionLogPath}/{functionName}/", cancellationToken))
{
Expand All @@ -118,14 +119,16 @@ internal async Task<string> ReadApplicationLogAsync(string functionName, int log
}
else
{
logger.WriteWarning($"Cannot get listing for {functionName} (attempt #{attempt}): {listingResponse.ReasonPhrase}");
Thread.Sleep(300);
logger.WriteWarning($"Cannot get listing for {functionName} (attempt #{attempt+1}): {listingResponse.ReasonPhrase}");
Thread.Sleep(delay[attempt]);
}
}
}

if (logIndex < 0) logIndex = listingResult.Length - 1;
logger.WriteVerbose($"Retrivining log #{logIndex}");
string logName = listingResult[logIndex].name;
logger.WriteVerbose($"Retrivining log '{logName}'");

logger.WriteVerbose($"Retrieving {logName} log");
using (var logRequest = await GetRequestAsync(HttpMethod.Get, $"{FunctionLogPath}/{functionName}/{logName}", cancellationToken))
Expand Down

0 comments on commit 10cc9a7

Please sign in to comment.