Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
17 changes: 4 additions & 13 deletions nexus/reconfigurator/execution/src/clickhouse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use futures::future::Either;
use futures::stream::FuturesUnordered;
use futures::stream::StreamExt;
use nexus_db_queries::context::OpContext;
use nexus_sled_agent_shared::inventory::OmicronZoneType;
use nexus_types::deployment::Blueprint;
use nexus_types::deployment::BlueprintZoneFilter;
use nexus_types::deployment::BlueprintZonesConfig;
use nexus_types::deployment::ClickhouseClusterConfig;
Expand Down Expand Up @@ -182,18 +182,9 @@ pub(crate) async fn deploy_single_node(
opctx: &OpContext,
zones: &BTreeMap<SledUuid, BlueprintZonesConfig>,
) -> Result<(), anyhow::Error> {
if let Some(zone) = zones
.values()
.flat_map(|zones| {
zones
.to_omicron_zones_config(BlueprintZoneFilter::ShouldBeRunning)
.zones
.into_iter()
.find(|zone| {
matches!(zone.zone_type, OmicronZoneType::Clickhouse { .. })
})
})
.next()
if let Some((_, zone)) =
Blueprint::filtered_zones(zones, BlueprintZoneFilter::ShouldBeRunning)
.find(|(_, zone)| zone.zone_type.is_clickhouse())
{
let admin_addr = SocketAddr::V6(SocketAddrV6::new(
zone.underlay_ip(),
Expand Down
4 changes: 3 additions & 1 deletion nexus/reconfigurator/execution/src/omicron_physical_disks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ pub(crate) async fn deploy_disks(
&log,
);
let result = client
.omicron_physical_disks_put(&config.clone().into())
.omicron_physical_disks_put(
&config.clone().into_in_service_disks(),
)
.await
.with_context(|| {
format!("Failed to put {config:#?} to sled {sled_id}")
Expand Down
5 changes: 2 additions & 3 deletions nexus/reconfigurator/execution/src/omicron_zones.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use nexus_db_queries::db::datastore::CollectorReassignment;
use nexus_db_queries::db::DataStore;
use nexus_types::deployment::BlueprintZoneConfig;
use nexus_types::deployment::BlueprintZoneDisposition;
use nexus_types::deployment::BlueprintZoneFilter;
use nexus_types::deployment::BlueprintZoneType;
use nexus_types::deployment::BlueprintZonesConfig;
use omicron_common::address::COCKROACH_ADMIN_PORT;
Expand Down Expand Up @@ -65,8 +64,8 @@ pub(crate) async fn deploy_zones(
db_sled.sled_agent_address(),
&opctx.log,
);
let omicron_zones = config
.to_omicron_zones_config(BlueprintZoneFilter::ShouldBeRunning);
let omicron_zones =
config.clone().into_running_omicron_zones_config();
let result = client
.omicron_zones_put(&omicron_zones)
.await
Expand Down
7 changes: 2 additions & 5 deletions nexus/reconfigurator/planning/src/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use crate::system::SledBuilder;
use crate::system::SystemDescription;
use nexus_inventory::CollectionBuilderRng;
use nexus_types::deployment::Blueprint;
use nexus_types::deployment::BlueprintZoneFilter;
use nexus_types::deployment::OmicronZoneNic;
use nexus_types::deployment::PlanningInput;
use nexus_types::deployment::SledFilter;
Expand Down Expand Up @@ -490,9 +489,7 @@ impl ExampleSystemBuilder {
system
.sled_set_omicron_zones(
*sled_id,
zones.to_omicron_zones_config(
BlueprintZoneFilter::ShouldBeRunning,
),
zones.clone().into_running_omicron_zones_config(),
)
.unwrap();
}
Expand Down Expand Up @@ -546,7 +543,7 @@ impl ZoneCount {
mod tests {
use chrono::{NaiveDateTime, TimeZone, Utc};
use nexus_sled_agent_shared::inventory::{OmicronZoneConfig, ZoneKind};
use nexus_types::deployment::BlueprintZoneConfig;
use nexus_types::deployment::{BlueprintZoneConfig, BlueprintZoneFilter};
use omicron_test_utils::dev::test_setup_log;

use super::*;
Expand Down
5 changes: 2 additions & 3 deletions nexus/reconfigurator/planning/src/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -976,9 +976,8 @@ mod test {
.blueprint_zones
.get(&new_sled_id)
.expect("blueprint should contain zones for new sled")
.to_omicron_zones_config(
BlueprintZoneFilter::ShouldBeRunning,
),
.clone()
.into_running_omicron_zones_config(),
)
.unwrap();
let collection =
Expand Down
81 changes: 46 additions & 35 deletions nexus/types/src/deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,33 +547,30 @@ pub struct BlueprintZonesConfig {
pub zones: IdMap<BlueprintZoneConfig>,
}

impl From<BlueprintZonesConfig> for OmicronZonesConfig {
fn from(config: BlueprintZonesConfig) -> Self {
Self {
generation: config.generation,
zones: config.zones.into_iter().map(From::from).collect(),
}
}
}

impl BlueprintZonesConfig {
/// Converts self to an [`OmicronZonesConfig`], applying the provided
/// [`BlueprintZoneFilter`].
/// Converts self into [`OmicronZonesConfig`].
///
/// The filter controls which zones should be exported into the resulting
/// [`OmicronZonesConfig`].
pub fn to_omicron_zones_config(
&self,
filter: BlueprintZoneFilter,
) -> OmicronZonesConfig {
/// [`OmicronZonesConfig`] is a format of the zones configuration that can
/// be passed to Sled Agents for deployment.
///
/// This function is effectively a `From` implementation, but
/// is named slightly more explicitly, as it filters the blueprint
/// configuration to only consider zones that should be running.
pub fn into_running_omicron_zones_config(self) -> OmicronZonesConfig {
OmicronZonesConfig {
generation: self.generation,
zones: self
.zones
.iter()
.filter(|z| z.disposition.matches(filter))
.cloned()
.map(OmicronZoneConfig::from)
.into_iter()
.filter_map(|z| {
if z.disposition
.matches(BlueprintZoneFilter::ShouldBeRunning)
{
Some(z.into())
} else {
None
}
})
.collect(),
}
}
Expand Down Expand Up @@ -899,6 +896,33 @@ pub struct BlueprintPhysicalDisksConfig {
pub disks: IdMap<BlueprintPhysicalDiskConfig>,
}

impl BlueprintPhysicalDisksConfig {
/// Converts self into [`OmicronPhysicalDisksConfig`].
///
/// [`OmicronPhysicalDisksConfig`] is a format of the disks configuration
/// that can be passed to Sled Agents for deployment.
///
/// This function is effectively a `From` implementation, but
/// is named slightly more explicitly, as it filters the blueprint
/// configuration to only consider in-service disks.
pub fn into_in_service_disks(self) -> OmicronPhysicalDisksConfig {
OmicronPhysicalDisksConfig {
generation: self.generation,
disks: self
.disks
.into_iter()
.filter_map(|d| {
if d.disposition.matches(DiskFilter::InService) {
Some(d.into())
} else {
None
}
})
.collect(),
}
}
}

impl IdMappable for BlueprintPhysicalDiskConfig {
type Id = PhysicalDiskUuid;

Expand Down Expand Up @@ -927,19 +951,6 @@ impl From<BlueprintPhysicalDiskConfig> for OmicronPhysicalDiskConfig {
}
}

impl From<BlueprintPhysicalDisksConfig> for OmicronPhysicalDisksConfig {
fn from(value: BlueprintPhysicalDisksConfig) -> Self {
OmicronPhysicalDisksConfig {
generation: value.generation,
disks: value
.disks
.into_iter()
.map(OmicronPhysicalDiskConfig::from)
.collect(),
}
}
}

/// Information about Omicron datasets as recorded in a blueprint.
#[derive(
Debug, Clone, Eq, PartialEq, JsonSchema, Deserialize, Serialize, Diffable,
Expand All @@ -950,7 +961,7 @@ pub struct BlueprintDatasetsConfig {
}

impl BlueprintDatasetsConfig {
/// Converts [Self] into [DatasetsConfig].
/// Converts self into [DatasetsConfig].
///
/// [DatasetsConfig] is a format of the dataset configuration that can be
/// passed to Sled Agents for deployment.
Expand Down
2 changes: 1 addition & 1 deletion sled-agent/src/rack_setup/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ impl ServiceInner {
// Ensure all the physical disks are initialized
self.initialize_disks_on_sled(
*sled_address,
config.disks.clone().into(),
config.disks.clone().into_in_service_disks(),
)
.await?;

Expand Down
Loading