From 354da6c438ad7df8a1eadd4637fc66a57890e5fb Mon Sep 17 00:00:00 2001 From: Haitao Mei Date: Wed, 14 Jun 2023 04:27:47 -0700 Subject: [PATCH] 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 --- .../integration/test-newadmin-blobstore.t | 2 +- .../admin/src/commands/blobstore_unlink.rs | 34 ++++++++++--------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/eden/mononoke/tests/integration/test-newadmin-blobstore.t b/eden/mononoke/tests/integration/test-newadmin-blobstore.t index ae0d338e47..2b3c2fe45c 100644 --- a/eden/mononoke/tests/integration/test-newadmin-blobstore.t +++ b/eden/mononoke/tests/integration/test-newadmin-blobstore.t @@ -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 diff --git a/eden/mononoke/tools/admin/src/commands/blobstore_unlink.rs b/eden/mononoke/tools/admin/src/commands/blobstore_unlink.rs index 4a947f9567..3fcaecf02e 100644 --- a/eden/mononoke/tools/admin/src/commands/blobstore_unlink.rs +++ b/eden/mononoke/tools/admin/src/commands/blobstore_unlink.rs @@ -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>, 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> = 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(())