Skip to content

Commit bd22075

Browse files
authored
[blippy] if mupdate override is set, check that host phase 2 is CurrentContents (#8706)
Same logic as for zones -- ensure that the desired host phase 2 contents are set to CurrentContents. This logic already exists within Sled Agent: https://github.com/oxidecomputer/omicron/blob/e732a78191b4988e655ac2abb08679f616c29723/sled-agent/config-reconciler/src/ledger.rs#L462-L471
1 parent e732a78 commit bd22075

File tree

2 files changed

+112
-9
lines changed

2 files changed

+112
-9
lines changed

nexus/reconfigurator/blippy/src/blippy.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use omicron_common::address::Ipv6Subnet;
1616
use omicron_common::address::SLED_PREFIX;
1717
use omicron_common::api::external::MacAddr;
1818
use omicron_common::disk::DatasetKind;
19+
use omicron_common::disk::M2Slot;
1920
use omicron_uuid_kinds::MupdateOverrideUuid;
2021
use omicron_uuid_kinds::SledUuid;
2122
use omicron_uuid_kinds::ZpoolUuid;
@@ -186,6 +187,12 @@ pub enum SledKind {
186187
version: BlueprintArtifactVersion,
187188
hash: ArtifactHash,
188189
},
190+
MupdateOverrideWithHostPhase2Artifact {
191+
mupdate_override_id: MupdateOverrideUuid,
192+
slot: M2Slot,
193+
version: BlueprintArtifactVersion,
194+
hash: ArtifactHash,
195+
},
189196
}
190197

191198
impl fmt::Display for SledKind {
@@ -395,6 +402,19 @@ impl fmt::Display for SledKind {
395402
zone.id,
396403
)
397404
}
405+
SledKind::MupdateOverrideWithHostPhase2Artifact {
406+
mupdate_override_id,
407+
slot,
408+
version,
409+
hash,
410+
} => {
411+
write!(
412+
f,
413+
"sled has remove_mupdate_override set ({mupdate_override_id}), \
414+
but host phase 2 slot {slot} image source is set to Artifact \
415+
(version {version}, hash {hash})",
416+
)
417+
}
398418
}
399419
}
400420
}

nexus/reconfigurator/blippy/src/checks.rs

Lines changed: 92 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use crate::blippy::SledKind;
88
use nexus_sled_agent_shared::inventory::ZoneKind;
99
use nexus_types::deployment::BlueprintDatasetConfig;
1010
use nexus_types::deployment::BlueprintDatasetDisposition;
11+
use nexus_types::deployment::BlueprintHostPhase2DesiredContents;
1112
use nexus_types::deployment::BlueprintPhysicalDiskDisposition;
1213
use nexus_types::deployment::BlueprintSledConfig;
1314
use nexus_types::deployment::BlueprintZoneConfig;
@@ -21,6 +22,8 @@ use omicron_common::address::DnsSubnet;
2122
use omicron_common::address::Ipv6Subnet;
2223
use omicron_common::address::SLED_PREFIX;
2324
use omicron_common::disk::DatasetKind;
25+
use omicron_common::disk::M2Slot;
26+
use omicron_uuid_kinds::MupdateOverrideUuid;
2427
use omicron_uuid_kinds::SledUuid;
2528
use omicron_uuid_kinds::ZpoolUuid;
2629
use std::collections::BTreeMap;
@@ -577,9 +580,21 @@ fn check_mupdate_override(blippy: &mut Blippy<'_>) {
577580
}
578581
}
579582

580-
// TODO: The host phase 2 contents should be set to CurrentContents
581-
// (waiting for
582-
// https://github.com/oxidecomputer/omicron/issues/8542).
583+
// The host phase 2 contents should be set to CurrentContents.
584+
check_mupdate_override_host_phase_2_contents(
585+
blippy,
586+
sled_id,
587+
mupdate_override_id,
588+
M2Slot::A,
589+
&sled.host_phase_2.slot_a,
590+
);
591+
check_mupdate_override_host_phase_2_contents(
592+
blippy,
593+
sled_id,
594+
mupdate_override_id,
595+
M2Slot::B,
596+
&sled.host_phase_2.slot_b,
597+
);
583598

584599
// TODO: PendingMgsUpdates for this sled should be empty. Mapping
585600
// sled IDs to their MGS identifiers (baseboard ID) requires a map
@@ -589,6 +604,30 @@ fn check_mupdate_override(blippy: &mut Blippy<'_>) {
589604
}
590605
}
591606

607+
fn check_mupdate_override_host_phase_2_contents(
608+
blippy: &mut Blippy<'_>,
609+
sled_id: SledUuid,
610+
mupdate_override_id: MupdateOverrideUuid,
611+
slot: M2Slot,
612+
contents: &BlueprintHostPhase2DesiredContents,
613+
) {
614+
match contents {
615+
BlueprintHostPhase2DesiredContents::Artifact { version, hash } => {
616+
blippy.push_sled_note(
617+
sled_id,
618+
Severity::Fatal,
619+
SledKind::MupdateOverrideWithHostPhase2Artifact {
620+
mupdate_override_id,
621+
slot,
622+
version: version.clone(),
623+
hash: *hash,
624+
},
625+
);
626+
}
627+
BlueprintHostPhase2DesiredContents::CurrentContents => {}
628+
}
629+
}
630+
592631
#[cfg(test)]
593632
mod tests {
594633
use super::*;
@@ -1637,7 +1676,7 @@ mod tests {
16371676
sled.remove_mupdate_override = Some(mupdate_override_id);
16381677

16391678
// Find a zone and set it to use an artifact image source.
1640-
let kind = {
1679+
let artifact_zone_kind = {
16411680
let mut zone = sled
16421681
.zones
16431682
.iter_mut()
@@ -1661,16 +1700,60 @@ mod tests {
16611700
}
16621701
};
16631702

1664-
let expected_note = Note {
1665-
severity: Severity::Fatal,
1666-
kind: Kind::Sled { sled_id, kind },
1703+
// Also set the host phase 2 contents.
1704+
let host_phase_2_a_kind = {
1705+
let version = BlueprintArtifactVersion::Available {
1706+
version: ArtifactVersion::new_const("123"),
1707+
};
1708+
let hash = ArtifactHash([2u8; 32]);
1709+
sled.host_phase_2.slot_a =
1710+
BlueprintHostPhase2DesiredContents::Artifact {
1711+
version: version.clone(),
1712+
hash,
1713+
};
1714+
SledKind::MupdateOverrideWithHostPhase2Artifact {
1715+
mupdate_override_id,
1716+
slot: M2Slot::A,
1717+
version,
1718+
hash,
1719+
}
16671720
};
16681721

1722+
let host_phase_2_b_kind = {
1723+
let version = BlueprintArtifactVersion::Unknown;
1724+
let hash = ArtifactHash([3u8; 32]);
1725+
sled.host_phase_2.slot_b =
1726+
BlueprintHostPhase2DesiredContents::Artifact {
1727+
version: version.clone(),
1728+
hash,
1729+
};
1730+
SledKind::MupdateOverrideWithHostPhase2Artifact {
1731+
mupdate_override_id,
1732+
slot: M2Slot::B,
1733+
version,
1734+
hash,
1735+
}
1736+
};
1737+
1738+
let expected_notes = vec![
1739+
Note {
1740+
severity: Severity::Fatal,
1741+
kind: Kind::Sled { sled_id, kind: artifact_zone_kind },
1742+
},
1743+
Note {
1744+
severity: Severity::Fatal,
1745+
kind: Kind::Sled { sled_id, kind: host_phase_2_a_kind },
1746+
},
1747+
Note {
1748+
severity: Severity::Fatal,
1749+
kind: Kind::Sled { sled_id, kind: host_phase_2_b_kind },
1750+
},
1751+
];
1752+
16691753
let report =
16701754
Blippy::new(&blueprint).into_report(BlippyReportSortKey::Kind);
16711755
eprintln!("{}", report.display());
1672-
assert_eq!(report.notes().len(), 1, "exactly one note expected");
1673-
assert_eq!(report.notes()[0], expected_note);
1756+
assert_eq!(report.notes(), &expected_notes);
16741757

16751758
logctx.cleanup_successful();
16761759
}

0 commit comments

Comments
 (0)