diff --git a/dev-tools/omdb/src/bin/omdb/db.rs b/dev-tools/omdb/src/bin/omdb/db.rs index 2b8d2512f1..53d83eb2af 100644 --- a/dev-tools/omdb/src/bin/omdb/db.rs +++ b/dev-tools/omdb/src/bin/omdb/db.rs @@ -33,6 +33,7 @@ use nexus_db_model::DnsGroup; use nexus_db_model::DnsName; use nexus_db_model::DnsVersion; use nexus_db_model::DnsZone; +use nexus_db_model::ExternalIp; use nexus_db_model::Instance; use nexus_db_model::Project; use nexus_db_model::Region; @@ -1133,10 +1134,18 @@ async fn cmd_db_eips( limit: NonZeroU32, verbose: bool, ) -> Result<(), anyhow::Error> { + /* let ips = datastore .lookup_external_ips(&opctx) .await .context("listing external ips")?; + */ + use db::schema::external_ip::dsl; + let ips: Vec = dsl::external_ip + .filter(dsl::time_deleted.is_null()) + .select(ExternalIp::as_select()) + .get_results_async(datastore.pool_for_tests().await?) + .await?; check_limit(&ips, limit, || String::from("listing external ips")); @@ -1199,7 +1208,7 @@ async fn cmd_db_eips( Owner::Service { kind: format!("{:?}", service.1.kind) } } else { use db::schema::instance::dsl as instance_dsl; - let instance = instance_dsl::instance + let instance = match instance_dsl::instance .filter(instance_dsl::id.eq(owner_id)) .limit(1) .select(Instance::as_select()) @@ -1207,10 +1216,16 @@ async fn cmd_db_eips( .await .context("loading requested instance")? .pop() - .context("requested instance not found")?; + { + Some(instance) => instance, + None => { + eprintln!("instance with id {owner_id} not found"); + continue; + } + }; use db::schema::project::dsl as project_dsl; - let project = project_dsl::project + let project = match project_dsl::project .filter(project_dsl::id.eq(instance.project_id)) .limit(1) .select(Project::as_select()) @@ -1218,7 +1233,16 @@ async fn cmd_db_eips( .await .context("loading requested project")? .pop() - .context("requested project not found")?; + { + Some(instance) => instance, + None => { + eprintln!( + "project with id {} not found", + instance.project_id + ); + continue; + } + }; Owner::Instance { project: project.name().to_string(), diff --git a/dev-tools/omdb/tests/successes.out b/dev-tools/omdb/tests/successes.out index ef806fb87f..b1464cb824 100644 --- a/dev-tools/omdb/tests/successes.out +++ b/dev-tools/omdb/tests/successes.out @@ -84,24 +84,6 @@ stderr: note: using database URL postgresql://root@[::1]:REDACTED_PORT/omicron?sslmode=disable note: database schema version matches expected (5.0.0) ============================================= -EXECUTING COMMAND: omdb ["db", "network"] -termination: Exited(2) ---------------------------------------------- -stdout: ---------------------------------------------- -stderr: -Print information about the network - -Usage: omdb db network [OPTIONS] - -Commands: - list-eips List external IPs - help Print this message or the help of the given subcommand(s) - -Options: - --verbose Print out raw data structures from the data store - -h, --help Print help -============================================= EXECUTING COMMAND: omdb ["nexus", "background-tasks", "doc"] termination: Exited(0) --------------------------------------------- diff --git a/dev-tools/omdb/tests/test_all_output.rs b/dev-tools/omdb/tests/test_all_output.rs index 7028ec5710..d757369ead 100644 --- a/dev-tools/omdb/tests/test_all_output.rs +++ b/dev-tools/omdb/tests/test_all_output.rs @@ -41,6 +41,7 @@ async fn test_omdb_usage_errors() { &["db", "dns", "diff"], &["db", "dns", "names"], &["db", "services"], + &["db", "network"], &["nexus"], &["nexus", "background-tasks"], &["sled-agent"], @@ -69,7 +70,6 @@ async fn test_omdb_success_cases(cptestctx: &ControlPlaneTestContext) { &["db", "services", "list-instances"], &["db", "services", "list-by-sled"], &["db", "sleds"], - &["db", "network"], &["nexus", "background-tasks", "doc"], &["nexus", "background-tasks", "show"], // We can't easily test the sled agent output because that's only diff --git a/dev-tools/omdb/tests/usage_errors.out b/dev-tools/omdb/tests/usage_errors.out index cebbb261ea..b5421b76af 100644 --- a/dev-tools/omdb/tests/usage_errors.out +++ b/dev-tools/omdb/tests/usage_errors.out @@ -188,6 +188,24 @@ Commands: Options: -h, --help Print help ============================================= +EXECUTING COMMAND: omdb ["db", "network"] +termination: Exited(2) +--------------------------------------------- +stdout: +--------------------------------------------- +stderr: +Print information about the network + +Usage: omdb db network [OPTIONS] + +Commands: + list-eips List external IPs + help Print this message or the help of the given subcommand(s) + +Options: + --verbose Print out raw data structures from the data store + -h, --help Print help +============================================= EXECUTING COMMAND: omdb ["nexus"] termination: Exited(2) --------------------------------------------- diff --git a/nexus/db-queries/src/db/datastore/external_ip.rs b/nexus/db-queries/src/db/datastore/external_ip.rs index 7633c31af3..268b284a0a 100644 --- a/nexus/db-queries/src/db/datastore/external_ip.rs +++ b/nexus/db-queries/src/db/datastore/external_ip.rs @@ -282,18 +282,4 @@ impl DataStore { .await .map_err(|e| public_error_from_diesel(e, ErrorHandler::Server)) } - - /// Fetch all external IP addresses of any kind for the provided instance - pub async fn lookup_external_ips( - &self, - opctx: &OpContext, - ) -> LookupResult> { - use db::schema::external_ip::dsl; - dsl::external_ip - .filter(dsl::time_deleted.is_null()) - .select(ExternalIp::as_select()) - .get_results_async(self.pool_authorized(opctx).await?) - .await - .map_err(|e| public_error_from_diesel_pool(e, ErrorHandler::Server)) - } }