diff options
author | Alex Auvolat <alex@adnab.me> | 2021-12-16 13:17:09 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-01-04 12:46:13 +0100 |
commit | 4d30e62db456097563c574b9dfd22b138d700087 (patch) | |
tree | 00c6790eb7dad952c8e4796731a4ff6e7c3613b6 /src/garage/admin.rs | |
parent | 0bbb6673e7ce703e470a3c2aad620ee5f009bc84 (diff) | |
download | garage-4d30e62db456097563c574b9dfd22b138d700087.tar.gz garage-4d30e62db456097563c574b9dfd22b138d700087.zip |
New buckets for 0.6.0: migration code and build files
Diffstat (limited to 'src/garage/admin.rs')
-rw-r--r-- | src/garage/admin.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/garage/admin.rs b/src/garage/admin.rs index 5599c53f..74b24584 100644 --- a/src/garage/admin.rs +++ b/src/garage/admin.rs @@ -19,6 +19,7 @@ use garage_model::bucket_alias_table::*; use garage_model::bucket_table::*; use garage_model::garage::Garage; use garage_model::key_table::*; +use garage_model::migrate::Migrate; use garage_model::permission::*; use crate::cli::*; @@ -31,6 +32,7 @@ pub enum AdminRpc { BucketOperation(BucketOperation), KeyOperation(KeyOperation), LaunchRepair(RepairOpt), + Migrate(MigrateOpt), Stats(StatsOpt), // Replies @@ -650,6 +652,22 @@ impl AdminRpcHandler { Ok(()) } + async fn handle_migrate(self: &Arc<Self>, opt: MigrateOpt) -> Result<AdminRpc, Error> { + if !opt.yes { + return Err(Error::BadRpc( + "Please provide the --yes flag to initiate migration operation.".to_string(), + )); + } + + let m = Migrate { + garage: self.garage.clone(), + }; + match opt.what { + MigrateWhat::Buckets050 => m.migrate_buckets050().await, + }?; + Ok(AdminRpc::Ok("Migration successfull.".into())) + } + async fn handle_launch_repair(self: &Arc<Self>, opt: RepairOpt) -> Result<AdminRpc, Error> { if !opt.yes { return Err(Error::BadRpc( @@ -819,6 +837,7 @@ impl EndpointHandler<AdminRpc> for AdminRpcHandler { match message { AdminRpc::BucketOperation(bo) => self.handle_bucket_cmd(bo).await, AdminRpc::KeyOperation(ko) => self.handle_key_cmd(ko).await, + AdminRpc::Migrate(opt) => self.handle_migrate(opt.clone()).await, AdminRpc::LaunchRepair(opt) => self.handle_launch_repair(opt.clone()).await, AdminRpc::Stats(opt) => self.handle_stats(opt.clone()).await, _ => Err(Error::BadRpc("Invalid RPC".to_string())), |