-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make
publisher
yank one crate at a time (#3324)
## Motivation and Context `P109001503` ## Description When `publisher` yanks crates, it blasts `crates.io` in parallel with all the yank requests, and then awaits their results. To avoid throttling errors, this PR instead yanks one crate at a time, with a configurable time delay in between via a `--delay-millis` command line argument. Further, a call to yank is now wrapped with `run_with_retry` to detect throttle errors, wait a long period of time after, and try again. Essentially, the structure of the `yank` module is now similar to that of the `publish` module such as use of `run_with_retry` and the presence of a CLI argument `delay-millis`. ## Testing On top of changes in the PR, manually modified the following for loop in `yank_release.rs` locally ``` for (crate_name, crate_version) in crates { ``` to ``` for (crate_name, crate_version) in [("aws-sigv4", "0.55.0"); 50] { // [email protected] has already been yanked in the past so it's safe to yank repeatedly ``` and observed the behavior of `publisher yank-release --delay-millis 2000` that it - waits 2 seconds beteen yanks - yanks in a serial manner ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
- Loading branch information
1 parent
24029ab
commit e7e2419
Showing
3 changed files
with
43 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,4 @@ pub mod publish; | |
pub mod retry; | ||
pub mod sort; | ||
pub mod subcommand; | ||
pub mod yank; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
use crate::cargo; | ||
use crate::retry::{run_with_retry, BoxError, ErrorClass}; | ||
use smithy_rs_tool_common::shell::ShellOperation; | ||
use std::time::Duration; | ||
use tracing::info; | ||
|
||
#[tracing::instrument] | ||
pub async fn yank(crate_name: &str, crate_version: &str) -> anyhow::Result<()> { | ||
info!("Yanking `{}-{}`...", crate_name, crate_version); | ||
run_with_retry( | ||
&format!("Yanking `{}-{}`", crate_name, crate_version), | ||
5, | ||
Duration::from_secs(60), | ||
|| async { | ||
cargo::Yank::new(crate_name, crate_version).spawn().await?; | ||
Result::<_, BoxError>::Ok(()) | ||
}, | ||
|_err| ErrorClass::Retry, | ||
) | ||
.await?; | ||
Ok(()) | ||
} |