Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More omdb improvements #7805

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Conversation

jmpesp
Copy link
Contributor

@jmpesp jmpesp commented Mar 17, 2025

Three improvements to omdb:

  • for the replacements-to-do command, show if there's an existing replacement request: display the id, request time, and state

  • add a sub-command to show if any volumes are cooked, aka unable to activate due to a region set containing all expunged targets

  • add a sub-command to show what volumes reference an ip, netmask, read-only region, or region snapshot

Three improvements to omdb:

- for the `replacements-to-do` command, show if there's an existing
  replacement request: display the id, request time, and state

- add a sub-command to show if any volumes are cooked, aka unable to
  activate due to a region set containing all expunged targets

- add a sub-command to show what volumes reference an ip, netmask,
  read-only region, or region snapshot
@jmpesp jmpesp requested a review from leftwo March 17, 2025 21:22
@leftwo
Copy link
Contributor

leftwo commented Mar 19, 2025

Some sample output:

root@oxz_switch0:~# /tmp/omdb-james-20250317 db replacements-to-do
note: database URL not specified.  Will search DNS.
note: (override with --db-url or OMDB_DB_URL)
note: using DNS server for subnet fd00:1122:3344::/48
note: (if this is not right, use --dns-server to specify an alternate DNS server)
note: using database URL postgresql://root@[fd00:1122:3344:109::3]:32221,[fd00:1122:3344:105::3]:32221,[fd00:1122:3344:10b::3]:32221,[fd00:1122:3344:107::3]:32221,[fd00:1122:3344:108::3]:32221/omicron?sslmode=disable
WARN: found schema version 129.0.0, expected 130.0.0
It's possible the database is running a version that's different from what this
tool understands.  This may result in errors or incorrect output.
ID                                   DATASET_ID                           RESOURCE          EXISTING_REQUEST_TIME    EXISTING_REQUEST                                      
ff29fe1d-1b09-486a-ab17-eddcd351921c eb71bb55-37fb-4fc4-bdee-a5382a480271 read/write region 2024-08-14T19:43:13.357Z 5c43d936-d5c4-4d4e-b1ca-890aabeeae87 (state Complete) 
27d353ae-984f-4ff1-ac74-a6853b27bce5 23e1cf01-70ab-422f-997b-6216158965c3 read/write region 2025-02-03T07:04:23.914Z 8ea8203f-5948-4fc9-91c2-5dcd43202ba1 (state Complete) 
390eadde-af95-48a7-8449-19eaed1562a5 23e1cf01-70ab-422f-997b-6216158965c3 read/write region 2025-02-03T07:04:24.106Z 515f4e2f-74a5-4042-afe4-027075116889 (state Complete) 
4046d4bb-5f7c-4d56-b31d-ec1171a369bc 23e1cf01-70ab-422f-997b-6216158965c3 read/write region 2025-02-03T07:04:24.175Z 13deaefa-af58-406d-98dd-5954016e728a (state Complete) 
c87906c6-88d2-4ad7-bcdd-3ebbe6ec4533 23e1cf01-70ab-422f-997b-6216158965c3 read/write region 2025-02-03T07:04:24.277Z dd42d36d-0095-4cc5-bc39-36d2f2e75a51 (state Complete) 
d3c0df6e-b1b7-4fa7-a0f9-49f2c4ba79b8 23e1cf01-70ab-422f-997b-6216158965c3 read/write region 2025-02-03T07:04:24.362Z 77aaf801-bdb4-456e-8c54-ad6da7f2c183 (state Complete) 

DATASET_ID                           REGION_ID                            SNAPSHOT_ID                          EXISTING_REQUEST_TIME EXISTING_REQUEST 
23e1cf01-70ab-422f-997b-6216158965c3 27d353ae-984f-4ff1-ac74-a6853b27bce5 c208f542-5012-42a7-938c-a32a888f9bbe                                        
23e1cf01-70ab-422f-997b-6216158965c3 390eadde-af95-48a7-8449-19eaed1562a5 c26a293b-8357-480f-af8a-d9b2e1da4145                                        
23e1cf01-70ab-422f-997b-6216158965c3 4046d4bb-5f7c-4d56-b31d-ec1171a369bc d22c42a6-0db4-4bca-b41f-7d0c10a3065d                                        
23e1cf01-70ab-422f-997b-6216158965c3 c87906c6-88d2-4ad7-bcdd-3ebbe6ec4533 f2261d8c-d6f6-405c-aa73-97c6fcca0648                                        
23e1cf01-70ab-422f-997b-6216158965c3 d3c0df6e-b1b7-4fa7-a0f9-49f2c4ba79b8 0af5053a-3127-4068-8986-52c3a190271f   

@leftwo
Copy link
Contributor

leftwo commented Mar 20, 2025

cooked output:

root@oxz_switch0:~# /tmp/omdb-james-20250320 db volumes cooked                                                                                                                    
note: database URL not specified.  Will search DNS.                                                                                                                               
note: (override with --db-url or OMDB_DB_URL)                                                                                                                                     
note: using DNS server for subnet fd00:1122:3344::/48                                                                                                                             
note: (if this is not right, use --dns-server to specify an alternate DNS server)                                                                                                 
note: using database URL postgresql://root@[fd00:1122:3344:109::3]:32221,[fd00:1122:3344:105::3]:32221,[fd00:1122:3344:10b::3]:32221,[fd00:1122:3344:107::3]:32221,[fd00:1122:3344
:108::3]:32221/omicron?sslmode=disable                                                                                                                                            
WARN: found schema version 131.0.0, expected 130.0.0                                                                                                                              
It's possible the database is running a version that's different from what this                                                                                                   
tool understands.  This may result in errors or incorrect output.                                                                                                                 
target [fd00:1122:3344:104::9]:19015 does not uniquely identify a resource, please run `omdb db validate` sub-commands related to volumes!                               
target [fd00:1122:3344:103::4]:19013 does not uniquely identify a resource, please run `omdb db validate` sub-commands related to volumes!                               
target [fd00:1122:3344:104::9]:19015 does not uniquely identify a resource, please run `omdb db validate` sub-commands related to volumes!                               
target [fd00:1122:3344:104::9]:19015 does not uniquely identify a resource, please run `omdb db validate` sub-commands related to volumes! 

Copy link
Contributor

@leftwo leftwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor things. This will be a useful tool improvement.

@@ -847,6 +852,10 @@ enum VolumeCommands {
List,
/// What is holding the lock?
LockHolder(VolumeLockHolderArgs),
/// What volumes are cooked (read: cannot activate)?
Cooked,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While Iove the cooked name, I think we might want a better one that describes what this command will returned. Invalid? illegal? And, also, the comment should not be a question :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The question part is for the help commands listing:

Commands:
  info         Get info for a specific volume
  list         Summarize current volumes
  lock-holder  What is holding the lock?
  cooked       What volumes are cooked (read: cannot activate)?
  reference    What volumes reference a thing?
  help         Print this message or the help of the given subcommand(s)

I've changed this to CannotActivate in 21d9658

#[clap(group(
ArgGroup::new("volume-reference-group")
.required(true)
.args(&["ip", "net", "read_only_region", "region_snapshot"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a question users are going to have is "what is the difference between a region_snapshot and just a snapshot". I don't know how to tell them. I also don't know what if anything we do different here.

VolumeCookedResult::TargetNotFound { target } => {
println!(
"target {target} not found (was probably \
deleted concurrently when `volume_cooked` was called)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not print the probably ... message here, as transient things like this can happen all over omdb and we make no guarantee that things remain static.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, done in 4d16c73

fetch_opts: &DbFetchOptions,
args: &VolumeReferenceArgs,
) -> Result<(), anyhow::Error> {
let volume_ids: Vec<Uuid> = if let Some(ip) = args.ip {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you are working on the "clap should not .." path through here already.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, 996da6e validates that three UUIDs are supplied

#[clap(long, conflicts_with_all = ["ip", "net", "region_snapshot"])]
read_only_region: Option<Uuid>,

/// Provide dataset, region, and snapshot ID in a string, delimited by
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This help comment here is what I need to see.

From the help output:
--region-snapshot <REGION_SNAPSHOT>
That makes it seem like I only need a single item. Is this part done by clap?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah. with 996da6e this now looks like --region_snapshot <REGION_SNAPSHOT> <REGION_SNAPSHOT> <REGION_SNAPSHOT> and I don't know how to fix it 👎

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in dea7c69

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants