Skip to content

Commit

Permalink
Find deleted volume regions
Browse files Browse the repository at this point in the history
  • Loading branch information
jmpesp committed Nov 1, 2023
1 parent 48f1229 commit f7b417e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
42 changes: 42 additions & 0 deletions dev-tools/omdb/src/bin/omdb/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ enum RegionCommands {

/// Find what is using a region
UsedBy(RegionUsedByArgs),

/// Find deleted volume regions
FindDeletedVolumeRegions,
}

#[derive(Debug, Args)]
Expand Down Expand Up @@ -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),
}) => {
Expand Down Expand Up @@ -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<Row> = 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,
Expand Down
4 changes: 4 additions & 0 deletions dev-tools/omdb/tests/usage_errors.out
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand Down

0 comments on commit f7b417e

Please sign in to comment.