Skip to content

Commit

Permalink
[reconfigurator] preserve sled state in example systems (#6731)
Browse files Browse the repository at this point in the history
While working on tests for decommissioned sled cleanup, I noticed that we
weren't preserving sled state in the `SystemDescription` used for example
systems.

There's another small change in here to store a `SledResources` in here rather
than its disaggregated form. This change makes some upcoming tests easier to
write.
  • Loading branch information
sunshowers authored Oct 1, 2024
1 parent 469522d commit 90b8499
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
1 change: 1 addition & 0 deletions dev-tools/reconfigurator-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,7 @@ fn cmd_load(
let result = sim.system.sled_full(
sled_id,
sled_details.policy,
sled_details.state,
sled_details.resources.clone(),
inventory_sp,
inventory_sled_agent,
Expand Down
28 changes: 16 additions & 12 deletions nexus/reconfigurator/planning/src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,16 @@ impl SystemDescription {
}

/// Add a sled to the system based on information that came from the
/// database of an existing system
/// database of an existing system.
///
/// Note that `sled_policy` and `sled_state` are currently not checked for
/// internal consistency! This is to permit testing of the Planner with
/// invalid inputs.
pub fn sled_full(
&mut self,
sled_id: SledUuid,
sled_policy: SledPolicy,
sled_state: SledState,
sled_resources: SledResources,
inventory_sp: Option<SledHwInventory<'_>>,
inventory_sled_agent: &nexus_types::inventory::SledAgent,
Expand All @@ -278,6 +283,7 @@ impl SystemDescription {
Sled::new_full(
sled_id,
sled_policy,
sled_state,
sled_resources,
inventory_sp,
inventory_sled_agent,
Expand Down Expand Up @@ -344,11 +350,8 @@ impl SystemDescription {
for sled in self.sleds.values() {
let sled_details = SledDetails {
policy: sled.policy,
state: SledState::Active,
resources: SledResources {
zpools: sled.zpools.clone(),
subnet: sled.sled_subnet,
},
state: sled.state,
resources: sled.resources.clone(),
};
builder.add_sled(sled.sled_id, sled_details)?;
}
Expand Down Expand Up @@ -455,11 +458,11 @@ pub struct SledHwInventory<'a> {
#[derive(Clone, Debug)]
struct Sled {
sled_id: SledUuid,
sled_subnet: Ipv6Subnet<SLED_PREFIX>,
inventory_sp: Option<(u16, SpState)>,
inventory_sled_agent: Inventory,
zpools: BTreeMap<ZpoolUuid, SledDisk>,
policy: SledPolicy,
state: SledState,
resources: SledResources,
}

impl Sled {
Expand Down Expand Up @@ -579,13 +582,13 @@ impl Sled {

Sled {
sled_id,
sled_subnet,
inventory_sp,
inventory_sled_agent,
zpools,
policy: SledPolicy::InService {
provision_policy: SledProvisionPolicy::Provisionable,
},
state: SledState::Active,
resources: SledResources { subnet: sled_subnet, zpools },
}
}

Expand All @@ -594,6 +597,7 @@ impl Sled {
fn new_full(
sled_id: SledUuid,
sled_policy: SledPolicy,
sled_state: SledState,
sled_resources: SledResources,
inventory_sp: Option<SledHwInventory<'_>>,
inv_sled_agent: &nexus_types::inventory::SledAgent,
Expand Down Expand Up @@ -714,11 +718,11 @@ impl Sled {

Sled {
sled_id,
sled_subnet: sled_resources.subnet,
zpools: sled_resources.zpools.into_iter().collect(),
inventory_sp,
inventory_sled_agent,
policy: sled_policy,
state: sled_state,
resources: sled_resources,
}
}

Expand Down

0 comments on commit 90b8499

Please sign in to comment.