Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Better retry policy in binstalk-downloader #794

Merged
merged 22 commits into from
Feb 13, 2023
Merged

Conversation

NobodyXu
Copy link
Member

@NobodyXu NobodyXu commented Feb 12, 2023

Fixed #779 #791

  • Retry request on timeout
  • Retry for StatusCode::{REQUEST_TIMEOUT, GATEWAY_TIMEOUT}
  • Add DEFAULT_RETRY_DURATION_FOR_RATE_LIMIT for 503/429
    if 503/429 does not give us a header or give us an invalid header on
    when to retry, we would default to
    DEFAULT_RETRY_DURATION_FOR_RATE_LIMIT.
  • Fix Client::get_redirected_final_url: Retry using GET on status code 400..405 + 410
  • Rename remote_exists => remote_gettable & support fallback to GET
    if HEAD fails due to status code 400..405 + 410.
  • Improve Client::get_stream: Include url & method in the err of the stream returned

Signed-off-by: Jiahao XU Jiahao_XU@outlook.com

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
if 503/429 does not give us a header or give us an invalid header on
when to retry, we would default to
`DEFAULT_RETRY_DURATION_FOR_RATE_LIMIT`.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
…NOT_ALLOWED`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
if `HEAD` fails due to `METHOD_NOT_ALLOWED`.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
/// Attempt to get final redirected url.
/// Check if remote exists using `Method::HEAD` or `Method::GET` as fallback.
pub async fn remote_gettable(&self, url: Url) -> Result<bool, Error> {
self.head_or_fallback_to_get(url)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using head_or_fallback_to_get would help improve the perf and reduce http timeout/rate limit since we would only fallback if GET is not allowed (for amazon s3).

@NobodyXu NobodyXu requested a review from passcod February 12, 2023 08:18
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
@NobodyXu
Copy link
Member Author

NobodyXu commented Feb 12, 2023

This PR also fixes our CI where we would fallback to cargo-install for miniserve and cargo-binstall v0.12/v0.11, confirmed by manually checking the output.

@NobodyXu
Copy link
Member Author

This PR also fixes our CI where we would fallback to cargo-install for miniserve and cargo-binstall v0.12/v0.11, confirmed by manually checking the output.

Turns out that this is still possible, CI test (x86_64-unknown-linux-musl, ubuntu-latest) just encountered this.

But I think this is likely caused by rate limiting from GH preventing cargo-binstall from accessing GH at all, so I think this is fine.

@NobodyXu NobodyXu requested review from passcod and removed request for passcod February 12, 2023 11:24
@NobodyXu NobodyXu changed the title Feature: More retry policy in binstalk-downloader Feature: Better retry policy in binstalk-downloader Feb 12, 2023
@@ -38,6 +38,7 @@ jobs:
runs-on: ${{ matrix.os }}
env:
CARGO_BUILD_TARGET: ${{ matrix.target }}
CARGO_BINSTALL_LOG_LEVEL: debug
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we set this to debug only if the action is in debug mode, so the logs are brief in the happy case?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed the justfile already does similarly so

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah because I forgot BINSTALL_LOG_LEVEL exists.
I clearly saw this when reviewing your PR but I guess we should document these behavior.

count += 1;

match self.do_send_request(method, url).await? {
ControlFlow::Break(response) => break Ok(response),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL about ops::ControlFlow!

@NobodyXu NobodyXu merged commit 87686cb into main Feb 13, 2023
@NobodyXu NobodyXu deleted the reqwest-retry branch February 13, 2023 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Supurious failure on CI: Failed to lookup address information
2 participants