mononoke: update admin to use new common cmdlib scrub action argument

Summary: Update to use the new common argument from cmdlib version

Reviewed By: krallin

Differential Revision: D25976404

fbshipit-source-id: a1089b82e6455254fed32317e76764498dcfa130
This commit is contained in:
Alex Hornby 2021-02-05 01:15:39 -08:00 committed by Facebook GitHub Bot
parent 539544af09
commit 0f25acc8ab
3 changed files with 6 additions and 20 deletions

View File

@ -15,7 +15,7 @@ use fbinit::FacebookInit;
use futures::{compat::Future01CompatExt, future::try_join};
use blobstore::{Blobstore, BlobstoreGetData};
use blobstore_factory::{make_blobstore, BlobstoreOptions, ReadOnlyStorage, ScrubAction};
use blobstore_factory::{make_blobstore, BlobstoreOptions, ReadOnlyStorage};
use cacheblob::{new_memcache_blobstore, CacheBlobstoreExt};
use cached_config::ConfigStore;
use cmdlib::args::{self, MononokeMatches};
@ -34,13 +34,11 @@ use sql_ext::facebook::MysqlOptions;
use std::collections::HashMap;
use std::ffi::OsStr;
use std::iter::FromIterator;
use std::str::FromStr;
use tokio::{fs::File, io::AsyncWriteExt};
use crate::error::SubcommandError;
pub const BLOBSTORE_FETCH: &str = "blobstore-fetch";
const SCRUB_BLOBSTORE_ACTION_ARG: &str = "scrub-blobstore-action";
const RAW_FILE_NAME_ARG: &str = "raw-blob";
pub fn build_subcommand<'a, 'b>() -> App<'a, 'b> {
@ -80,13 +78,6 @@ pub fn build_subcommand<'a, 'b>() -> App<'a, 'b> {
.required(false)
.help("If main blobstore in the storage config is a multiplexed one, use inner blobstore with this id")
)
.arg(
Arg::with_name(SCRUB_BLOBSTORE_ACTION_ARG)
.long(SCRUB_BLOBSTORE_ACTION_ARG)
.takes_value(true)
.required(false)
.help("Enable ScrubBlobstore with the given action. Checks for keys missing from stores. In ReportOnly mode this logs only, otherwise it performs a copy to the missing stores."),
)
.arg(
Arg::with_name(RAW_FILE_NAME_ARG)
.long(RAW_FILE_NAME_ARG)
@ -159,14 +150,8 @@ pub async fn subcommand_blobstore_fetch<'a>(
let redaction = config.redaction;
let storage_config = config.storage_config;
let inner_blobstore_id = args::get_u64_opt(&sub_m, "inner-blobstore-id");
let scrub_action = sub_m
.value_of(SCRUB_BLOBSTORE_ACTION_ARG)
.map(ScrubAction::from_str)
.transpose()
.map_err(Error::from)?;
let mysql_options = args::parse_mysql_options(&matches);
let blobstore_options =
args::parse_blobstore_options(&matches)?.with_scrub_action(scrub_action);
let blobstore_options = args::parse_blobstore_options(&matches)?;
let readonly_storage = args::parse_readonly_storage(&matches);
let blobstore_fut = get_blobstore(

View File

@ -13,7 +13,7 @@ use blobstore::PutBehaviour;
use fbinit::FacebookInit;
use std::process::ExitCode;
use cmdlib::args::{self, MononokeClapApp};
use cmdlib::args::{self, ArgType, MononokeClapApp};
use context::CoreContext;
use slog::error;
@ -59,6 +59,7 @@ mod subcommand_unodes;
fn setup_app<'a, 'b>() -> MononokeClapApp<'a, 'b> {
args::MononokeAppBuilder::new("Mononoke admin command line tool")
.with_arg_types(vec![ArgType::Scrub])
.with_advanced_args_hidden()
.with_source_and_target_repos()
.with_special_put_behaviour(PutBehaviour::Overwrite)

View File

@ -63,14 +63,14 @@ Check blobstore-fetch, with scrub actions
$ ls blobstore/1/blobs | wc -l
29
$ mononoke_admin blobstore-fetch --scrub-blobstore-action=ReportOnly changeset.blake2.c3384961b16276f2db77df9d7c874bbe981cf0525bd6f84a502f919044f2dabd 2>&1 | strip_glog
$ mononoke_admin --blobstore-scrub-action=ReportOnly blobstore-fetch changeset.blake2.c3384961b16276f2db77df9d7c874bbe981cf0525bd6f84a502f919044f2dabd 2>&1 | strip_glog
using blobstore: *ScrubBlobstore* (glob)
scrub: blobstore_id BlobstoreId(1) not repaired for repo0000.changeset.blake2.c3384961b16276f2db77df9d7c874bbe981cf0525bd6f84a502f919044f2dabd
Some(BlobstoreGetData* (glob)
$ ls blobstore/1/blobs | wc -l
29
$ mononoke_admin blobstore-fetch --scrub-blobstore-action=Repair changeset.blake2.c3384961b16276f2db77df9d7c874bbe981cf0525bd6f84a502f919044f2dabd 2>&1 | strip_glog
$ mononoke_admin --blobstore-scrub-action=Repair blobstore-fetch changeset.blake2.c3384961b16276f2db77df9d7c874bbe981cf0525bd6f84a502f919044f2dabd 2>&1 | strip_glog
using blobstore: *ScrubBlobstore* (glob)
scrub: blobstore_id BlobstoreId(1) repaired for repo0000.changeset.blake2.c3384961b16276f2db77df9d7c874bbe981cf0525bd6f84a502f919044f2dabd
Some(BlobstoreGetData* (glob)