Skip to content

Commit ca96cf3

Browse files
authored
BlueprintBuilder: remove SledEditor::baseboard_id() (#9405)
`SledEditor` was storing each sled's baseboard ID, but: * it's only available via `PlanningInput`, and putting it directly into the blueprint is difficult for mostly-irrelevant reasons * there was only one caller of `SledEditor::baseboard_id()`: `sled_ensure_mupdate_override()` (to match up sled ID <-> baseboard ID) * `sled_ensure_mupdate_override()` itself only has one caller, the planner, which already knows the baseboard ID of the sled it's ensuring So this PR removes `SledEditor::baseboard_id()` entirely, and has the planner pass the baseboard ID in. (On the update watercooler today we also mentioned the possibility of a separate `BlueprintBuilder::clear_pending_mgs_updates(baseboard_id)` method, but that's tricky to implement because some nontrivial logic for "should we clear pending MGS updates" is nested inside `SledEditor` itself.)
1 parent 69dc064 commit ca96cf3

File tree

3 files changed

+12
-43
lines changed

3 files changed

+12
-43
lines changed

nexus/reconfigurator/planning/src/blueprint_builder/builder.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,6 @@ impl<'a> BlueprintBuilder<'a> {
631631
)
632632
})?;
633633
SledEditor::for_existing_active(
634-
Arc::new(details.baseboard_id.clone()),
635634
details.resources.subnet,
636635
sled_cfg.clone(),
637636
)
@@ -652,7 +651,6 @@ impl<'a> BlueprintBuilder<'a> {
652651
for (sled_id, details) in input.all_sleds(SledFilter::Commissioned) {
653652
if let Entry::Vacant(slot) = sled_editors.entry(sled_id) {
654653
slot.insert(SledEditor::for_new_active(
655-
Arc::new(details.baseboard_id.clone()),
656654
details.resources.subnet,
657655
));
658656
}
@@ -1299,6 +1297,7 @@ impl<'a> BlueprintBuilder<'a> {
12991297
pub(crate) fn sled_ensure_mupdate_override(
13001298
&mut self,
13011299
sled_id: SledUuid,
1300+
baseboard_id: &BaseboardId,
13021301
// inv_mupdate_override_info has a weird type (not Option<&T>, not &str)
13031302
// because this is what `Result::as_ref` returns.
13041303
inv_mupdate_override_info: Result<
@@ -1312,13 +1311,6 @@ impl<'a> BlueprintBuilder<'a> {
13121311
"tried to ensure mupdate override for unknown sled {sled_id}"
13131312
))
13141313
})?;
1315-
let baseboard_id = editor.baseboard_id().ok_or_else(|| {
1316-
// All commissioned sleds have baseboards; this should never fail.
1317-
Error::Planner(anyhow!(
1318-
"tried to ensure mupdate override for \
1319-
decommissioned sled {sled_id}"
1320-
))
1321-
})?;
13221314

13231315
// Also map the editor to the corresponding PendingMgsUpdates.
13241316
let pending_mgs_update = self.pending_mgs_updates.entry(baseboard_id);

nexus/reconfigurator/planning/src/blueprint_editor/sled_editor.rs

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ use nexus_types::deployment::BlueprintZoneType;
3636
use nexus_types::deployment::PendingMgsUpdate;
3737
use nexus_types::deployment::blueprint_zone_type;
3838
use nexus_types::external_api::views::SledState;
39-
use nexus_types::inventory::BaseboardId;
4039
use omicron_common::address::Ipv6Subnet;
4140
use omicron_common::address::SLED_PREFIX;
4241
use omicron_common::api::external::Generation;
@@ -51,7 +50,6 @@ use scalar::ScalarEditor;
5150
use std::iter;
5251
use std::mem;
5352
use std::net::Ipv6Addr;
54-
use std::sync::Arc;
5553
use underlay_ip_allocator::SledUnderlayIpAllocator;
5654

5755
mod datasets;
@@ -162,7 +160,6 @@ enum InnerSledEditor {
162160

163161
impl SledEditor {
164162
pub fn for_existing_active(
165-
baseboard_id: Arc<BaseboardId>,
166163
subnet: Ipv6Subnet<SLED_PREFIX>,
167164
config: BlueprintSledConfig,
168165
) -> Result<Self, SledInputError> {
@@ -171,7 +168,7 @@ impl SledEditor {
171168
SledState::Active,
172169
"for_existing_active called on non-active sled"
173170
);
174-
let inner = ActiveSledEditor::new(baseboard_id, subnet, config)?;
171+
let inner = ActiveSledEditor::new(subnet, config)?;
175172
Ok(Self(InnerSledEditor::Active(inner)))
176173
}
177174

@@ -191,14 +188,8 @@ impl SledEditor {
191188
Ok(Self(InnerSledEditor::Decommissioned(inner)))
192189
}
193190

194-
pub fn for_new_active(
195-
baseboard_id: Arc<BaseboardId>,
196-
subnet: Ipv6Subnet<SLED_PREFIX>,
197-
) -> Self {
198-
Self(InnerSledEditor::Active(ActiveSledEditor::new_empty(
199-
baseboard_id,
200-
subnet,
201-
)))
191+
pub fn for_new_active(subnet: Ipv6Subnet<SLED_PREFIX>) -> Self {
192+
Self(InnerSledEditor::Active(ActiveSledEditor::new_empty(subnet)))
202193
}
203194

204195
pub fn finalize(self) -> EditedSled {
@@ -215,15 +206,6 @@ impl SledEditor {
215206
}
216207
}
217208

218-
/// Returns the baseboard of this sled if it is active, or `None` if it is
219-
/// decommissioned.
220-
pub fn baseboard_id(&self) -> Option<&Arc<BaseboardId>> {
221-
match &self.0 {
222-
InnerSledEditor::Active(active) => Some(&active.baseboard_id),
223-
InnerSledEditor::Decommissioned(_) => None,
224-
}
225-
}
226-
227209
/// Returns the subnet of this sled if it is active, or `None` if it is
228210
/// decommissioned.
229211
pub fn subnet(&self) -> Option<Ipv6Subnet<SLED_PREFIX>> {
@@ -261,10 +243,9 @@ impl SledEditor {
261243
// below, we'll be left in the active state with an empty sled
262244
// editor), but omicron in general is not panic safe and aborts
263245
// on panic. Plus `finalize()` should never panic.
264-
let mut stolen = ActiveSledEditor::new_empty(
265-
Arc::clone(&editor.baseboard_id),
266-
Ipv6Subnet::new(Ipv6Addr::LOCALHOST),
267-
);
246+
let mut stolen = ActiveSledEditor::new_empty(Ipv6Subnet::new(
247+
Ipv6Addr::LOCALHOST,
248+
));
268249
mem::swap(editor, &mut stolen);
269250

270251
let mut finalized = stolen.finalize();
@@ -506,7 +487,6 @@ impl SledEditor {
506487

507488
#[derive(Debug)]
508489
struct ActiveSledEditor {
509-
baseboard_id: Arc<BaseboardId>,
510490
underlay_ip_allocator: SledUnderlayIpAllocator,
511491
incoming_sled_agent_generation: Generation,
512492
zones: ZonesEditor,
@@ -526,7 +506,6 @@ pub(crate) struct EditedSled {
526506

527507
impl ActiveSledEditor {
528508
pub fn new(
529-
baseboard_id: Arc<BaseboardId>,
530509
subnet: Ipv6Subnet<SLED_PREFIX>,
531510
config: BlueprintSledConfig,
532511
) -> Result<Self, SledInputError> {
@@ -541,7 +520,6 @@ impl ActiveSledEditor {
541520
zones.zones(BlueprintZoneDisposition::any).map(|z| z.underlay_ip());
542521

543522
Ok(Self {
544-
baseboard_id,
545523
underlay_ip_allocator: SledUnderlayIpAllocator::new(
546524
subnet, zone_ips,
547525
),
@@ -557,10 +535,7 @@ impl ActiveSledEditor {
557535
})
558536
}
559537

560-
pub fn new_empty(
561-
baseboard_id: Arc<BaseboardId>,
562-
subnet: Ipv6Subnet<SLED_PREFIX>,
563-
) -> Self {
538+
pub fn new_empty(subnet: Ipv6Subnet<SLED_PREFIX>) -> Self {
564539
// Creating the underlay IP allocator can only fail if we have a zone
565540
// with an IP outside the sled subnet, but we don't have any zones at
566541
// all, so this can't fail. Match explicitly to guard against this error
@@ -569,7 +544,6 @@ impl ActiveSledEditor {
569544
SledUnderlayIpAllocator::new(subnet, iter::empty());
570545

571546
Self {
572-
baseboard_id,
573547
underlay_ip_allocator,
574548
incoming_sled_agent_generation: Generation::new(),
575549
zones: ZonesEditor::empty(),

nexus/reconfigurator/planning/src/planner.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1835,7 +1835,9 @@ impl<'a> Planner<'a> {
18351835

18361836
// We use the list of in-service sleds here -- we don't want to alter
18371837
// expunged or decommissioned sleds.
1838-
for sled_id in self.input.all_sled_ids(SledFilter::InService) {
1838+
for (sled_id, sled_details) in
1839+
self.input.all_sleds(SledFilter::InService)
1840+
{
18391841
let log = log.new(o!("sled_id" => sled_id.to_string()));
18401842
let Some(inv_sled) = self.inventory.sled_agents.get(&sled_id)
18411843
else {
@@ -1844,6 +1846,7 @@ impl<'a> Planner<'a> {
18441846
};
18451847
let action = self.blueprint.sled_ensure_mupdate_override(
18461848
sled_id,
1849+
&sled_details.baseboard_id,
18471850
inv_sled
18481851
.zone_image_resolver
18491852
.mupdate_override

0 commit comments

Comments
 (0)