Skip to content

Commit

Permalink
WIP: fix incorrect filters
Browse files Browse the repository at this point in the history
  • Loading branch information
internet-diglett committed Jun 26, 2024
1 parent 6461078 commit fbe46a0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
6 changes: 3 additions & 3 deletions nexus/db-queries/src/db/datastore/v2p_mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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<_> =
Expand All @@ -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(),
Expand Down
16 changes: 5 additions & 11 deletions nexus/src/app/background/v2p_mappings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -44,23 +42,19 @@ 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) => {
let msg = format!("failed to enumerate sleds: {:#}", e);
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(),
Expand Down

0 comments on commit fbe46a0

Please sign in to comment.