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

Fix filters for probe v2p mappings #5960

Merged
merged 5 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dev-tools/omdb/tests/usage_errors.out
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ Options:
for discretionary services)
- query-during-inventory: Sleds whose sled agents should be queried for inventory
- reservation-create: Sleds on which reservations can be created
- v2p-mapping: Sleds which should be sent OPTE V2P mappings
- vpc-routing: Sleds which should be sent OPTE V2P mappings
- vpc-firewall: Sleds which should be sent VPC firewall rules

--log-level <LOG_LEVEL>
Expand Down
10 changes: 5 additions & 5 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 @@ -66,7 +67,7 @@ impl DataStore {
.filter(
network_interface::kind.eq(NetworkInterfaceKind::Instance),
)
.sled_filter(SledFilter::V2PMapping)
.sled_filter(SledFilter::VpcRouting)
.select((
NetworkInterface::as_select(),
Sled::as_select(),
Expand All @@ -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,10 +115,8 @@ 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),
)
.sled_filter(SledFilter::V2PMapping)
.filter(network_interface::kind.eq(NetworkInterfaceKind::Probe))
.sled_filter(SledFilter::VpcRouting)
.select((
NetworkInterface::as_select(),
Sled::as_select(),
Expand Down
16 changes: 5 additions & 11 deletions nexus/src/app/background/tasks/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::VpcRouting).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
2 changes: 1 addition & 1 deletion nexus/src/app/background/tasks/vpc_routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl BackgroundTask for VpcRouteManager {

let sleds = match self
.datastore
.sled_list_all_batched(opctx, SledFilter::InService)
.sled_list_all_batched(opctx, SledFilter::VpcRouting)
.await
{
Ok(v) => v,
Expand Down
12 changes: 6 additions & 6 deletions nexus/types/src/deployment/planning_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ pub enum SledFilter {
ReservationCreate,

/// Sleds which should be sent OPTE V2P mappings.
V2PMapping,
VpcRouting,

/// Sleds which should be sent VPC firewall rules.
VpcFirewall,
Expand Down Expand Up @@ -541,7 +541,7 @@ impl SledPolicy {
SledFilter::InService => true,
SledFilter::QueryDuringInventory => true,
SledFilter::ReservationCreate => true,
SledFilter::V2PMapping => true,
SledFilter::VpcRouting => true,
SledFilter::VpcFirewall => true,
},
SledPolicy::InService {
Expand All @@ -553,7 +553,7 @@ impl SledPolicy {
SledFilter::InService => true,
SledFilter::QueryDuringInventory => true,
SledFilter::ReservationCreate => false,
SledFilter::V2PMapping => true,
SledFilter::VpcRouting => true,
SledFilter::VpcFirewall => true,
},
SledPolicy::Expunged => match filter {
Expand All @@ -563,7 +563,7 @@ impl SledPolicy {
SledFilter::InService => false,
SledFilter::QueryDuringInventory => false,
SledFilter::ReservationCreate => false,
SledFilter::V2PMapping => false,
SledFilter::VpcRouting => false,
SledFilter::VpcFirewall => false,
},
}
Expand Down Expand Up @@ -595,7 +595,7 @@ impl SledState {
SledFilter::InService => true,
SledFilter::QueryDuringInventory => true,
SledFilter::ReservationCreate => true,
SledFilter::V2PMapping => true,
SledFilter::VpcRouting => true,
SledFilter::VpcFirewall => true,
},
SledState::Decommissioned => match filter {
Expand All @@ -605,7 +605,7 @@ impl SledState {
SledFilter::InService => false,
SledFilter::QueryDuringInventory => false,
SledFilter::ReservationCreate => false,
SledFilter::V2PMapping => false,
SledFilter::VpcRouting => false,
SledFilter::VpcFirewall => false,
},
}
Expand Down
Loading