From f7b417e2ad4786cd1d04990fe7b31baf95e966e4 Mon Sep 17 00:00:00 2001 From: James MacMahon Date: Wed, 1 Nov 2023 10:46:55 -0400 Subject: [PATCH] Find deleted volume regions --- dev-tools/omdb/src/bin/omdb/db.rs | 42 +++++++++++++++++++++++++++ dev-tools/omdb/tests/usage_errors.out | 4 +++ 2 files changed, 46 insertions(+) diff --git a/dev-tools/omdb/src/bin/omdb/db.rs b/dev-tools/omdb/src/bin/omdb/db.rs index dd1c179f9c..64546ad567 100644 --- a/dev-tools/omdb/src/bin/omdb/db.rs +++ b/dev-tools/omdb/src/bin/omdb/db.rs @@ -269,6 +269,9 @@ enum RegionCommands { /// Find what is using a region UsedBy(RegionUsedByArgs), + + /// Find deleted volume regions + FindDeletedVolumeRegions, } #[derive(Debug, Args)] @@ -485,6 +488,9 @@ impl DbArgs { ) .await } + DbCommands::Regions(RegionArgs { + command: RegionCommands::FindDeletedVolumeRegions, + }) => cmd_db_regions_find_deleted(&datastore).await, DbCommands::Sagas(SagaArgs { command: SagaCommands::List(saga_list_args), }) => { @@ -2785,6 +2791,42 @@ async fn cmd_db_regions_used_by( Ok(()) } +/// Find deleted volume regions +async fn cmd_db_regions_find_deleted( + datastore: &DataStore, +) -> Result<(), anyhow::Error> { + let datasets_regions_volumes = + datastore.find_deleted_volume_regions().await?; + + #[derive(Tabled)] + struct Row { + dataset_id: Uuid, + region_id: Uuid, + volume_id: Uuid, + } + + let rows: Vec = datasets_regions_volumes + .into_iter() + .map(|row| { + let (dataset, region, volume) = row; + + Row { + dataset_id: dataset.id(), + region_id: region.id(), + volume_id: volume.id(), + } + }) + .collect(); + + let table = tabled::Table::new(rows) + .with(tabled::settings::Style::psql()) + .to_string(); + + println!("{}", table); + + Ok(()) +} + fn print_name( prefix: &str, name: &str, diff --git a/dev-tools/omdb/tests/usage_errors.out b/dev-tools/omdb/tests/usage_errors.out index 6ab6cb33fc..0f613d2f10 100644 --- a/dev-tools/omdb/tests/usage_errors.out +++ b/dev-tools/omdb/tests/usage_errors.out @@ -96,6 +96,8 @@ Commands: sleds Print information about sleds instances Print information about customer instances network Print information about the network + regions Print information related to regions + sagas Print information related to sagas snapshots Print information about snapshots help Print this message or the help of the given subcommand(s) @@ -119,6 +121,8 @@ Commands: sleds Print information about sleds instances Print information about customer instances network Print information about the network + regions Print information related to regions + sagas Print information related to sagas snapshots Print information about snapshots help Print this message or the help of the given subcommand(s)