newadmin tool now deletes keys from all the related blobstores II

Summary: We handle the error gracefully, when deleting a key from the underlying blobstores.

Reviewed By: RajivTS

Differential Revision: D46684795

fbshipit-source-id: 45349aab01e56b11fd1ab455aec2bb69d72c497b
This commit is contained in:
Haitao Mei 2023-06-14 04:27:47 -07:00 committed by Facebook GitHub Bot
parent 6e0743ebfc
commit 354da6c438
2 changed files with 19 additions and 17 deletions

View File

@ -35,7 +35,7 @@ doesn't construct the blobstore in the usual way, so we need to give the full
key.
$ mononoke_newadmin blobstore-unlink -R repo repo0000.somekey
Unlinking key repo0000.somekey
Unlinking key repo0000.somekey successfully in one underlying blobstore
$ mononoke_newadmin blobstore -R repo fetch -q somekey -o "$TESTTMP/fetched_value_unlinked"
No blob exists for somekey

View File

@ -10,7 +10,6 @@ use std::sync::Arc;
use anyhow::bail;
use anyhow::format_err;
use anyhow::Context;
use anyhow::Error;
use anyhow::Result;
use blobstore::BlobstoreUnlinkOps;
@ -129,15 +128,7 @@ async fn get_multiple_blobstores(
config_store: &ConfigStore,
) -> Result<Vec<Arc<dyn BlobstoreUnlinkOps>>, Error> {
let blobstores = match blobconfig {
MultiplexedWal {
multiplex_id: _,
blobstores,
write_quorum: _,
queue_db: _,
inner_blobstores_scuba_table: _,
multiplex_scuba_table: _,
scuba_sample_rate: _,
} => {
MultiplexedWal { blobstores, .. } => {
let mut underlying_blobstores: Vec<Arc<dyn BlobstoreUnlinkOps>> = Vec::new();
writeln!(
std::io::stdout(),
@ -234,13 +225,24 @@ pub async fn run(app: MononokeApp, args: CommandArgs) -> Result<()> {
)
.await?;
writeln!(std::io::stdout(), "Unlinking key {}", args.key)?;
for blobstore in blobstores {
blobstore
.unlink(&ctx, &args.key)
.await
.context("Failed to unlink blob")?;
match blobstore.unlink(&ctx, &args.key).await {
Ok(_) => {
writeln!(
std::io::stdout(),
"Unlinking key {} successfully in one underlying blobstore",
args.key
)?;
}
Err(e) => {
writeln!(
std::io::stdout(),
"Failed to unlink key {} in one underlying blobstore, error: {}.",
args.key,
e
)?;
}
}
}
Ok(())