From 90b84996c0af1791773e3943bee21fdc42efdd9f Mon Sep 17 00:00:00 2001 From: Rain Date: Mon, 30 Sep 2024 20:11:56 -0700 Subject: [PATCH] [reconfigurator] preserve sled state in example systems (#6731) 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. --- dev-tools/reconfigurator-cli/src/main.rs | 1 + nexus/reconfigurator/planning/src/system.rs | 28 ++++++++++++--------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/dev-tools/reconfigurator-cli/src/main.rs b/dev-tools/reconfigurator-cli/src/main.rs index e994bc95f4..188319b665 100644 --- a/dev-tools/reconfigurator-cli/src/main.rs +++ b/dev-tools/reconfigurator-cli/src/main.rs @@ -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, diff --git a/nexus/reconfigurator/planning/src/system.rs b/nexus/reconfigurator/planning/src/system.rs index cc5c3430c1..ccb4d4ab27 100644 --- a/nexus/reconfigurator/planning/src/system.rs +++ b/nexus/reconfigurator/planning/src/system.rs @@ -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>, inventory_sled_agent: &nexus_types::inventory::SledAgent, @@ -278,6 +283,7 @@ impl SystemDescription { Sled::new_full( sled_id, sled_policy, + sled_state, sled_resources, inventory_sp, inventory_sled_agent, @@ -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)?; } @@ -455,11 +458,11 @@ pub struct SledHwInventory<'a> { #[derive(Clone, Debug)] struct Sled { sled_id: SledUuid, - sled_subnet: Ipv6Subnet, inventory_sp: Option<(u16, SpState)>, inventory_sled_agent: Inventory, - zpools: BTreeMap, policy: SledPolicy, + state: SledState, + resources: SledResources, } impl Sled { @@ -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 }, } } @@ -594,6 +597,7 @@ impl Sled { fn new_full( sled_id: SledUuid, sled_policy: SledPolicy, + sled_state: SledState, sled_resources: SledResources, inventory_sp: Option>, inv_sled_agent: &nexus_types::inventory::SledAgent, @@ -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, } }