From fbe46a0de8117163ff1f12f623c58ea32e7ecd48 Mon Sep 17 00:00:00 2001 From: Levon Tarver Date: Tue, 25 Jun 2024 15:58:16 +0000 Subject: [PATCH] WIP: fix incorrect filters --- nexus/db-queries/src/db/datastore/v2p_mapping.rs | 6 +++--- nexus/src/app/background/v2p_mappings.rs | 16 +++++----------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/nexus/db-queries/src/db/datastore/v2p_mapping.rs b/nexus/db-queries/src/db/datastore/v2p_mapping.rs index 2f54dfb9be..9ab9657b61 100644 --- a/nexus/db-queries/src/db/datastore/v2p_mapping.rs +++ b/nexus/db-queries/src/db/datastore/v2p_mapping.rs @@ -35,6 +35,7 @@ impl DataStore { opctx.check_complex_operations_allowed()?; + // Query for instance v2p mappings let mut mappings = Vec::new(); let mut paginator = Paginator::new(SQL_BATCH_SIZE); while let Some(p) = paginator.next() { @@ -92,6 +93,7 @@ impl DataStore { mappings.extend(batch); } + // Query for probe v2p mappings let mut paginator = Paginator::new(SQL_BATCH_SIZE); while let Some(p) = paginator.next() { let batch: Vec<_> = @@ -113,9 +115,7 @@ impl DataStore { ) .inner_join(sled_dsl::sled.on(sled_dsl::id.eq(probe_dsl::sled))) .filter(network_interface::time_deleted.is_null()) - .filter( - network_interface::kind.eq(NetworkInterfaceKind::Instance), - ) + .filter(network_interface::kind.eq(NetworkInterfaceKind::Probe)) .sled_filter(SledFilter::V2PMapping) .select(( NetworkInterface::as_select(), diff --git a/nexus/src/app/background/v2p_mappings.rs b/nexus/src/app/background/v2p_mappings.rs index e2318f94d6..7cc33ce684 100644 --- a/nexus/src/app/background/v2p_mappings.rs +++ b/nexus/src/app/background/v2p_mappings.rs @@ -2,12 +2,10 @@ use std::{collections::HashSet, sync::Arc}; use futures::future::BoxFuture; use futures::FutureExt; -use nexus_db_model::{Sled, SledState}; +use nexus_db_model::Sled; use nexus_db_queries::{context::OpContext, db::DataStore}; use nexus_networking::sled_client_from_address; -use nexus_types::{ - deployment::SledFilter, external_api::views::SledPolicy, identity::Asset, -}; +use nexus_types::{deployment::SledFilter, identity::Asset}; use omicron_common::api::external::Vni; use serde_json::json; use sled_agent_client::types::VirtualNetworkInterfaceHost; @@ -44,7 +42,7 @@ impl BackgroundTask for V2PManager { // Get sleds // we only care about sleds that are active && inservice - let sleds = match self.datastore.sled_list_all_batched(opctx, SledFilter::InService).await + let sleds = match self.datastore.sled_list_all_batched(opctx, SledFilter::V2PMapping).await { Ok(v) => v, Err(e) => { @@ -52,15 +50,11 @@ impl BackgroundTask for V2PManager { error!(&log, "{msg}"); return json!({"error": msg}); } - } - .into_iter() - .filter(|sled| { - matches!(sled.state(), SledState::Active) - && matches!(sled.policy(), SledPolicy::InService { .. }) - }); + }; // Map sled db records to sled-agent clients let sled_clients: Vec<(Sled, sled_agent_client::Client)> = sleds + .into_iter() .map(|sled| { let client = sled_client_from_address( sled.id(),