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

[7/n] [reconfigurator] combine inventory and omicron zones #6739

Merged
38 changes: 15 additions & 23 deletions dev-tools/omdb/src/bin/omdb/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5182,31 +5182,23 @@ fn inv_collection_print_sleds(collection: &Collection) {
println!(" reservation: {reservation:?}, quota: {quota:?}");
}

if let Some(zones) = collection.omicron_zones.get(&sled.sled_id) {
println!(
" zones collected from {} at {}",
zones.source, zones.time_collected,
);
println!(
" zones generation: {} (count: {})",
zones.zones.generation,
zones.zones.zones.len()
);
println!(
" zones generation: {} (count: {})",
sled.omicron_zones.generation,
sled.omicron_zones.zones.len(),
);

if zones.zones.zones.is_empty() {
continue;
}
if sled.omicron_zones.zones.is_empty() {
continue;
}

println!(" ZONES FOUND");
for z in &zones.zones.zones {
println!(
" zone {} (type {})",
z.id,
z.zone_type.kind().report_str()
);
}
} else {
println!(" warning: no zone information found");
println!(" ZONES FOUND");
for z in &sled.omicron_zones.zones {
println!(
" zone {} (type {})",
z.id,
z.zone_type.kind().report_str()
);
}
}
}
Expand Down
19 changes: 1 addition & 18 deletions dev-tools/reconfigurator-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use nexus_reconfigurator_planning::planner::Planner;
use nexus_reconfigurator_planning::system::{
SledBuilder, SledHwInventory, SystemDescription,
};
use nexus_sled_agent_shared::inventory::OmicronZonesConfig;
use nexus_sled_agent_shared::inventory::SledRole;
use nexus_sled_agent_shared::inventory::ZoneKind;
use nexus_types::deployment::BlueprintZoneFilter;
Expand Down Expand Up @@ -657,24 +656,8 @@ fn cmd_inventory_list(
fn cmd_inventory_generate(
sim: &mut ReconfiguratorSim,
) -> anyhow::Result<Option<String>> {
let mut builder =
let builder =
sim.system.to_collection_builder().context("generating inventory")?;
// For an inventory we just generated from thin air, pretend like each sled
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this change the behavior here?

Copy link
Contributor Author

@sunshowers sunshowers Oct 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does -- and I think what I was intending to do here was to try and figure out what this really means. I'll work on reconfigurator-cli in another PR that this depends on.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put up a few more PRs in the series, and established this behavior change via new tests. I think it makes sense -- the system now carries around zone information so it's weird for the inventory to ignore it.

// has no zones on it.
let planning_input =
sim.system.to_planning_input_builder().unwrap().build();
for sled_id in planning_input.all_sled_ids(SledFilter::Commissioned) {
builder
.found_sled_omicron_zones(
"fake sled agent",
sled_id,
OmicronZonesConfig {
generation: Generation::new(),
zones: vec![],
},
)
.context("recording Omicron zones")?;
}
let inventory = builder.build();
let rv = format!(
"generated inventory collection {} from configured sleds",
Expand Down
1 change: 1 addition & 0 deletions nexus-sled-agent-shared/src/inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ pub struct Inventory {
pub usable_hardware_threads: u32,
pub usable_physical_ram: ByteCount,
pub reservoir_size: ByteCount,
pub omicron_zones: OmicronZonesConfig,
pub disks: Vec<InventoryDisk>,
pub zpools: Vec<InventoryZpool>,
pub datasets: Vec<InventoryDataset>,
Expand Down
34 changes: 11 additions & 23 deletions nexus/db-model/src/inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ use diesel::serialize::ToSql;
use diesel::{serialize, sql_types};
use ipnetwork::IpNetwork;
use nexus_sled_agent_shared::inventory::OmicronZoneDataset;
use nexus_sled_agent_shared::inventory::{
OmicronZoneConfig, OmicronZoneType, OmicronZonesConfig,
};
use nexus_sled_agent_shared::inventory::{OmicronZoneConfig, OmicronZoneType};
use nexus_types::inventory::{
BaseboardId, Caboose, Collection, NvmeFirmware, PowerState, RotPage,
RotSlot,
Expand Down Expand Up @@ -1175,7 +1173,11 @@ impl From<InvDataset> for nexus_types::inventory::Dataset {
}
}

/// See [`nexus_types::inventory::OmicronZonesFound`].
/// Information about a sled's Omicron zones, part of
/// [`nexus_types::inventory::SledAgent`].
///
/// TODO: This table is vestigial and can be combined with `InvSledAgent`. See
/// https://github.com/oxidecomputer/omicron/issues/6770.
#[derive(Queryable, Clone, Debug, Selectable, Insertable)]
#[diesel(table_name = inv_sled_omicron_zones)]
pub struct InvSledOmicronZones {
Expand All @@ -1189,28 +1191,14 @@ pub struct InvSledOmicronZones {
impl InvSledOmicronZones {
pub fn new(
inv_collection_id: CollectionUuid,
zones_found: &nexus_types::inventory::OmicronZonesFound,
sled_agent: &nexus_types::inventory::SledAgent,
) -> InvSledOmicronZones {
InvSledOmicronZones {
inv_collection_id: inv_collection_id.into(),
time_collected: zones_found.time_collected,
source: zones_found.source.clone(),
sled_id: zones_found.sled_id.into(),
generation: Generation(zones_found.zones.generation),
}
}

pub fn into_uninit_zones_found(
self,
) -> nexus_types::inventory::OmicronZonesFound {
nexus_types::inventory::OmicronZonesFound {
time_collected: self.time_collected,
source: self.source,
sled_id: self.sled_id.into(),
zones: OmicronZonesConfig {
generation: *self.generation,
zones: Vec::new(),
},
time_collected: sled_agent.time_collected,
source: sled_agent.source.clone(),
sled_id: sled_agent.sled_id.into(),
generation: Generation(sled_agent.omicron_zones.generation),
}
}
}
Expand Down
8 changes: 2 additions & 6 deletions nexus/db-queries/src/db/datastore/deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1869,7 +1869,7 @@ mod tests {
) -> (Collection, PlanningInput, Blueprint) {
// We'll start with an example system.
let (mut base_collection, planning_input, mut blueprint) =
example(log, test_name, 3);
example(log, test_name);

// Take a more thorough collection representative (includes SPs,
// etc.)...
Expand All @@ -1882,10 +1882,6 @@ mod tests {
&mut collection.sled_agents,
&mut base_collection.sled_agents,
);
mem::swap(
&mut collection.omicron_zones,
&mut base_collection.omicron_zones,
);

// Treat this blueprint as the initial blueprint for the system.
blueprint.parent_blueprint_id = None;
Expand Down Expand Up @@ -1999,7 +1995,7 @@ mod tests {
);
assert_eq!(
blueprint1.blueprint_zones.len(),
collection.omicron_zones.len()
collection.sled_agents.len()
);
assert_eq!(
blueprint1.all_omicron_zones(BlueprintZoneFilter::All).count(),
Expand Down
Loading
Loading