-
Notifications
You must be signed in to change notification settings - Fork 36
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
[omdb] Add omdb instance info
command
#6610
Conversation
This is great, I've wanted instance info, but not taken the time to write it. Should I expect it to work for destroyed instances (granted some fields will be empty)?
but:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like @leftwo's idea about considering displaying soft-deleted instances as such. (I might do that with an ad hoc query in OMDB, though, similar to what cmd_db_instances
does, so as not to introduce an "ignore time_deleted" flag into the datastore.) Otherwise this LGTM with a couple small comments.
// /!\ WARNING /!\ | ||
// This does mean that anyone who adds new fields to the | ||
// `nexus_db_model::Instance` type will want to make sure to update this | ||
// code as well. Unfortunately, we can't just destructure the struct here to | ||
// make sure this code breaks, since the `identity` field isn't public. | ||
// So...just don't forget to do that, I guess. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have a similar warning over in nexus_db_model
?
Co-authored-by: Greg Colombo <[email protected]>
Regarding soft-deleted instances...the reason we currently don't report them here is because I had wanted to reuse the |
Okay, as of e3013e7, we now also handle deleted instances. For example: root@oxz_switch1:~# /var/tmp/omdb-eliza-test-14 db instance show fff916c4-814a-48a0-a04a-f887e6f81a9e
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
note: database schema version matches expected (98.0.0)
(i) instance has been deleted
INSTANCE
ID: fff916c4-814a-48a0-a04a-f887e6f81a9e
project ID: fe0da422-5c48-4b52-8010-f2fc401f090f
name: app-13
description: application instance
created at: 2024-06-22 00:31:43.889412 UTC
last modified at: 2024-06-22 00:31:43.889412 UTC
deleted at: 2024-06-22 00:43:59.156149 UTC
CONFIGURATION
vCPUs: 1
memory: 2 GiB
hostname: node13
auto-restart policy: None
RUNTIME STATE
state: Destroyed
last updated at: 2024-06-22T00:43:49.440274Z (generation 5)
active VMM ID: None
target VMM ID: None
migration ID: None
updater lock: UNLOCKED at generation: 1 |
Some last, unnecessary formatting tweaks: oot@oxz_switch1:~# /var/tmp/omdb-eliza-test-15 db instance show fff916c4-814a-48a0-a04a-f887e6f81a9e
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
note: database schema version matches expected (98.0.0)
INSTANCE
ID: fff916c4-814a-48a0-a04a-f887e6f81a9e
project ID: fe0da422-5c48-4b52-8010-f2fc401f090f
name: app-13
description: application instance
created at: 2024-06-22 00:31:43.889412 UTC
last modified at: 2024-06-22 00:31:43.889412 UTC
/!\ deleted at: 2024-06-22 00:43:59.156149 UTC
CONFIGURATION
vCPUs: 1
memory: 2 GiB
hostname: node13
auto-restart policy: None
RUNTIME STATE
nexus state: Destroyed
(i) external API state: Destroyed
last updated at: 2024-06-22T00:43:49.440274Z (generation 5)
active VMM ID: None
target VMM ID: None
migration ID: None
updater lock: UNLOCKED at generation: 1
root@oxz_switch1:~# /var/tmp/omdb-eliza-test-15 db instance show 480c6167-dac2-4df7-808d-c9e776c1c312
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
note: database schema version matches expected (98.0.0)
INSTANCE
ID: 480c6167-dac2-4df7-808d-c9e776c1c312
project ID: fe0da422-5c48-4b52-8010-f2fc401f090f
name: mysql-3
description: MySQL Instance
created at: 2024-09-16 00:43:10.264333 UTC
last modified at: 2024-09-16 00:43:10.264333 UTC
CONFIGURATION
vCPUs: 4
memory: 16 GiB
hostname: mysql-3
auto-restart policy: None
RUNTIME STATE
nexus state: Vmm
(i) external API state: Stopping
last updated at: 2024-09-19T23:15:50.698207Z (generation 5)
active VMM ID: Some(51babee3-0ee5-4f67-bcbb-2189a39479a3)
target VMM ID: None
migration ID: None
updater lock: UNLOCKED at generation: 4
active VMM record:
Vmm {
id: 51babee3-0ee5-4f67-bcbb-2189a39479a3,
time_created: 2024-09-19T23:15:50.647454Z,
time_deleted: None,
instance_id: 480c6167-dac2-4df7-808d-c9e776c1c312,
sled_id: 71def415-55ad-46b4-ba88-3ca55d7fb287,
propolis_ip: V6(
Ipv6Network {
addr: fd00:1122:3344:10b::1:4be,
prefix: 128,
},
),
propolis_port: SqlU16(
12400,
),
runtime: VmmRuntimeState {
time_state_updated: 2024-09-19T23:18:03.015643Z,
gen: Generation(
Generation(
4,
),
),
state: Stopping,
},
}
root@oxz_switch1:~# I think this is pretty good now if either of y'all want to review it again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for showing the deleted instances too
Presently,
omdb
can be used to query the database for instance recordsusing the
omdb instances
command. However, this command does notoutput all the database state associated with an instance. Instead, it
displays the instance's name, UUID, effective state, active Propolis
UUID, sled UUID, and sled serial (the last three only if the instance is
running).
This is some of the most useful information about a customer instance,
but it's not all of the information we have about it. Debugging issues
related to instance state management may require other information from
the instance record, as well as from the instance's active VMM record,
and its target VMM and active migration records (if it is migrating).
Adding all of these additional details to the
omdb db instances
command is a bit of a non-starter, though. Since that command outputs a
table of all instances, with one line per instance, the output is
already much wider than 80 columns, and requires a pretty wide
terminal to be readable --- once the table has line wrapped, it's much
harder to interpret. Therefore, I've added an
omdb db instance info
command that outputs a complete dump of the state of a single
instance. Since this command is no longer constrained to putting all
salient details about the instance on a single line in a table, we can
show every field in the instance's DB representation without having to
worry about wrapping.
Output from
omdb db instance info
looks like this (yes, I spententirely too long tweaking the formatting 😅):
I've also added
omdb db instance list
(orinstance ls
) as a subcommand ofomdb db instance
, but these are simply aliased to the currentdb instances
command. It just seemed nice to have additional verbs.