[AZI-529] improve log forwarder retry behavior #596
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Retries sending logs if the HTTP request failed. It will retry up to 4 times, with a 1 second timeout between retries, doubling each time. It will not retry http 4xx responses.
Motivation
The network connection can be flaky and it is worth retrying a failed request.
Testing Guidelines
Ran unit tests and tested in the Azure portal.
To test request errors, I constructed a bad http request with invalid options, and saw it attempt to retry the request. You can see the retry backoff in the timestamps.

Retrying based on status code. It doesn't retry on a 404, but does retry with a 500.

There was also a random timeout that got retried:

Additional Notes
Is 4 retries too much/not enough? How is a 1 sec timeout interval? Will doubling the timeout cause it to wait too long?
Without using external libraries, the only way to add a delay is with
setTimeout, which requires a callback to be provided.Types of changes
Check all that apply