Skip to content

Commit

Permalink
oldadmin: delete crossrepo pushredirection prepare-rollout subcommand
Browse files Browse the repository at this point in the history
Summary: The `crossrepo pushredirection prepare-rollout` subcommand has been migrated from old admin to newadmin. Let's delete the old admin version.

Reviewed By: singhsrb

Differential Revision: D64335894

fbshipit-source-id: 1f3c8b30237bd888f1a291cd797c21b05f3fac03
  • Loading branch information
YousefSalama authored and facebook-github-bot committed Oct 15, 2024
1 parent 3a976eb commit 4164215
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 69 deletions.
1 change: 0 additions & 1 deletion eden/mononoke/TARGETS
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ rust_binary(
"//eden/mononoke/bookmarks:bookmarks_movement",
"//eden/mononoke/changesets/changesets_creation:changesets_creation",
"//eden/mononoke/cmdlib:cmdlib",
"//eden/mononoke/commit_rewriting/backsyncer:backsyncer",
"//eden/mononoke/commit_rewriting/cross_repo_sync:cross_repo_sync",
"//eden/mononoke/commit_rewriting/live_commit_sync_config:live_commit_sync_config",
"//eden/mononoke/commit_rewriting/synced_commit_mapping:synced_commit_mapping",
Expand Down
1 change: 0 additions & 1 deletion eden/mononoke/admin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ path = "../cmds/admin/main.rs"

[dependencies]
anyhow = "1.0.86"
backsyncer = { version = "0.1.0", path = "../commit_rewriting/backsyncer" }
blame = { version = "0.1.0", path = "../derived_data/blame" }
blobrepo_hg = { version = "0.1.0", path = "../blobrepo/blobrepo_hg" }
blobstore = { version = "0.1.0", path = "../blobstore" }
Expand Down
65 changes: 0 additions & 65 deletions eden/mononoke/cmds/admin/crossrepo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use std::sync::Arc;
use anyhow::anyhow;
use anyhow::format_err;
use anyhow::Error;
use backsyncer::format_counter as format_backsyncer_counter;
use blobstore::Loadable;
use blobstore_factory::MetadataSqlFactory;
use blobstore_factory::ReadOnlyStorage;
Expand All @@ -20,11 +19,9 @@ use bonsai_globalrev_mapping::BonsaiGlobalrevMapping;
use bonsai_hg_mapping::BonsaiHgMapping;
use bookmarks::BookmarkKey;
use bookmarks::BookmarkUpdateLog;
use bookmarks::BookmarkUpdateLogRef;
use bookmarks::BookmarkUpdateReason;
use bookmarks::Bookmarks;
use bookmarks::BookmarksRef;
use bookmarks::Freshness;
use cached_config::ConfigStore;
use changesets_creation::save_changesets;
use clap_old::App;
Expand Down Expand Up @@ -70,7 +67,6 @@ use mononoke_types::GitLfs;
use mononoke_types::NonRootMPath;
use mononoke_types::RepositoryId;
use mutable_counters::MutableCounters;
use mutable_counters::MutableCountersRef;
use phases::Phases;
use pushrebase::do_pushrebase_bonsai;
use pushrebase::FAIL_PUSHREBASE_EXTRA;
Expand All @@ -96,7 +92,6 @@ const AUTHOR_ARG: &str = "author";
const DATE_ARG: &str = "date";
const ONCALL_ARG: &str = "oncall";
const DUMP_MAPPING_LARGE_REPO_PATH_ARG: &str = "dump-mapping-large-repo-path";
const PREPARE_ROLLOUT_SUBCOMMAND: &str = "prepare-rollout";
const PUSHREDIRECTION_SUBCOMMAND: &str = "pushredirection";
const LARGE_REPO_BOOKMARK_ARG: &str = "large-repo-bookmark";
const CHANGE_MAPPING_VERSION_SUBCOMMAND: &str = "change-mapping-version";
Expand Down Expand Up @@ -212,62 +207,6 @@ async fn run_pushredirection_subcommand<'a>(
let live_commit_sync_config: Arc<dyn LiveCommitSyncConfig> = Arc::new(live_commit_sync_config);

match config_subcommand_matches.subcommand() {
(PREPARE_ROLLOUT_SUBCOMMAND, Some(_sub_m)) => {
let commit_syncer = get_large_to_small_commit_syncer(
&ctx,
source_repo,
target_repo,
live_commit_sync_config.clone(),
)
.await?;

if live_commit_sync_config
.push_redirector_enabled_for_public(
&ctx,
commit_syncer.get_small_repo().repo_identity().id(),
)
.await?
{
return Err(format_err!(
"not allowed to run {} if pushredirection is enabled",
PREPARE_ROLLOUT_SUBCOMMAND
)
.into());
}

let small_repo = commit_syncer.get_small_repo();
let large_repo = commit_syncer.get_large_repo();
let largest_id = large_repo
.bookmark_update_log()
.get_largest_log_id(ctx.clone(), Freshness::MostRecent)
.await?
.ok_or_else(|| anyhow!("No bookmarks update log entries for large repo"))?;

let counter = format_backsyncer_counter(&large_repo.repo_identity().id());
info!(
ctx.logger(),
"setting value {} to counter {} for repo {}",
largest_id,
counter,
small_repo.repo_identity().id()
);
let res = small_repo
.mutable_counters()
.set_counter(
&ctx,
&counter,
largest_id.try_into().unwrap(),
None, // prev_value
)
.await?;

if !res {
return Err(anyhow!("failed to set backsyncer counter").into());
}
info!(ctx.logger(), "successfully updated the counter");

Ok(())
}
(CHANGE_MAPPING_VERSION_SUBCOMMAND, Some(sub_m)) => {
let commit_syncer = get_large_to_small_commit_syncer(
&ctx,
Expand Down Expand Up @@ -713,9 +652,6 @@ async fn move_bookmark(
}

pub fn build_subcommand<'a, 'b>() -> App<'a, 'b> {
let prepare_rollout_subcommand = SubCommand::with_name(PREPARE_ROLLOUT_SUBCOMMAND)
.about("command to prepare rollout of pushredirection");

let change_mapping_version = SubCommand::with_name(CHANGE_MAPPING_VERSION_SUBCOMMAND)
.about(
"a command to change mapping version for a given bookmark. \
Expand Down Expand Up @@ -775,7 +711,6 @@ pub fn build_subcommand<'a, 'b>() -> App<'a, 'b> {

let pushredirection_subcommand = SubCommand::with_name(PUSHREDIRECTION_SUBCOMMAND)
.about("helper commands to enable/disable pushredirection")
.subcommand(prepare_rollout_subcommand)
.subcommand(change_mapping_version);

SubCommand::with_name(CROSSREPO).subcommand(pushredirection_subcommand)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Setup configuration

Before the change
-- push to a small repo
$ quiet mononoke_admin_source_target $REPOIDLARGE $REPOIDSMALL crossrepo \
$ quiet mononoke_newadmin cross-repo --source-repo-id $REPOIDLARGE --target-repo-id $REPOIDSMALL \
> pushredirection prepare-rollout

$ enable_pushredirect 1
Expand Down Expand Up @@ -46,7 +46,7 @@ Before the change
> --author author \
> --large-repo-bookmark master_bookmark \
> --version-name new_version &> /dev/null
$ mononoke_admin_source_target $REPOIDLARGE $REPOIDSMALL crossrepo \
$ mononoke_newadmin cross-repo --source-repo-id $REPOIDLARGE --target-repo-id $REPOIDSMALL \
> pushredirection prepare-rollout &> /dev/null

$ enable_pushredirect 1 false true
Expand Down

0 comments on commit 4164215

Please sign in to comment.