Skip to content

Commit d8f30c1

Browse files
authored
[reconfigurator] database support for PendingMgsUpdate for host phase 1 (#8791)
This is more of the same as the other PendingMgsUpdate database implementations, plus a small bugfix that affected RoT and bootloader database storage.
1 parent f423987 commit d8f30c1

File tree

7 files changed

+478
-21
lines changed

7 files changed

+478
-21
lines changed

nexus/db-model/src/deployment.rs

Lines changed: 68 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::omicron_zone_config::{self, OmicronZoneNic};
1010
use crate::typed_uuid::DbTypedUuid;
1111
use crate::{
1212
ArtifactHash, ByteCount, DbArtifactVersion, DbOximeterReadMode, Generation,
13-
MacAddr, Name, SledState, SqlU8, SqlU16, SqlU32, TufArtifact,
13+
HwM2Slot, MacAddr, Name, SledState, SqlU8, SqlU16, SqlU32, TufArtifact,
1414
impl_enum_type, ipv6,
1515
};
1616
use anyhow::{Context, Result, anyhow, bail};
@@ -22,12 +22,11 @@ use nexus_db_schema::schema::{
2222
bp_clickhouse_keeper_zone_id_to_node_id,
2323
bp_clickhouse_server_zone_id_to_node_id, bp_omicron_dataset,
2424
bp_omicron_physical_disk, bp_omicron_zone, bp_omicron_zone_nic,
25-
bp_oximeter_read_policy, bp_pending_mgs_update_rot,
26-
bp_pending_mgs_update_rot_bootloader, bp_pending_mgs_update_sp,
27-
bp_sled_metadata, bp_target,
25+
bp_oximeter_read_policy, bp_pending_mgs_update_host_phase_1,
26+
bp_pending_mgs_update_rot, bp_pending_mgs_update_rot_bootloader,
27+
bp_pending_mgs_update_sp, bp_sled_metadata, bp_target,
2828
};
2929
use nexus_sled_agent_shared::inventory::OmicronZoneDataset;
30-
use nexus_types::deployment::BlueprintHostPhase2DesiredContents;
3130
use nexus_types::deployment::BlueprintHostPhase2DesiredSlots;
3231
use nexus_types::deployment::BlueprintPhysicalDiskConfig;
3332
use nexus_types::deployment::BlueprintPhysicalDiskDisposition;
@@ -44,6 +43,9 @@ use nexus_types::deployment::{
4443
BlueprintArtifactVersion, BlueprintDatasetConfig, OximeterReadMode,
4544
};
4645
use nexus_types::deployment::{BlueprintDatasetDisposition, ExpectedVersion};
46+
use nexus_types::deployment::{
47+
BlueprintHostPhase2DesiredContents, PendingMgsUpdateHostPhase1Details,
48+
};
4749
use nexus_types::deployment::{BlueprintZoneImageSource, blueprint_zone_type};
4850
use nexus_types::deployment::{
4951
OmicronZoneExternalFloatingAddr, OmicronZoneExternalFloatingIp,
@@ -1440,3 +1442,64 @@ impl BpPendingMgsUpdateComponent for BpPendingMgsUpdateRot {
14401442
}
14411443
}
14421444
}
1445+
1446+
#[derive(Queryable, Clone, Debug, Selectable, Insertable)]
1447+
#[diesel(table_name = bp_pending_mgs_update_host_phase_1)]
1448+
pub struct BpPendingMgsUpdateHostPhase1 {
1449+
pub blueprint_id: DbTypedUuid<BlueprintKind>,
1450+
pub hw_baseboard_id: Uuid,
1451+
pub sp_type: SpType,
1452+
pub sp_slot: SpMgsSlot,
1453+
pub artifact_sha256: ArtifactHash,
1454+
pub artifact_version: DbArtifactVersion,
1455+
pub expected_active_phase_1_slot: HwM2Slot,
1456+
pub expected_boot_disk: HwM2Slot,
1457+
pub expected_active_phase_1_hash: ArtifactHash,
1458+
pub expected_active_phase_2_hash: ArtifactHash,
1459+
pub expected_inactive_phase_1_hash: ArtifactHash,
1460+
pub expected_inactive_phase_2_hash: ArtifactHash,
1461+
sled_agent_ip: ipv6::Ipv6Addr,
1462+
sled_agent_port: SqlU16,
1463+
}
1464+
1465+
impl BpPendingMgsUpdateComponent for BpPendingMgsUpdateHostPhase1 {
1466+
fn hw_baseboard_id(&self) -> &Uuid {
1467+
&self.hw_baseboard_id
1468+
}
1469+
1470+
fn into_generic(self, baseboard_id: Arc<BaseboardId>) -> PendingMgsUpdate {
1471+
PendingMgsUpdate {
1472+
baseboard_id,
1473+
sp_type: self.sp_type.into(),
1474+
slot_id: **self.sp_slot,
1475+
artifact_hash: self.artifact_sha256.into(),
1476+
artifact_version: (*self.artifact_version).clone(),
1477+
details: PendingMgsUpdateDetails::HostPhase1(
1478+
PendingMgsUpdateHostPhase1Details {
1479+
expected_active_phase_1_slot: self
1480+
.expected_active_phase_1_slot
1481+
.into(),
1482+
expected_boot_disk: self.expected_boot_disk.into(),
1483+
expected_active_phase_1_hash: self
1484+
.expected_active_phase_1_hash
1485+
.into(),
1486+
expected_active_phase_2_hash: self
1487+
.expected_active_phase_2_hash
1488+
.into(),
1489+
expected_inactive_phase_1_hash: self
1490+
.expected_inactive_phase_1_hash
1491+
.into(),
1492+
expected_inactive_phase_2_hash: self
1493+
.expected_inactive_phase_2_hash
1494+
.into(),
1495+
sled_agent_address: SocketAddrV6::new(
1496+
self.sled_agent_ip.into(),
1497+
*self.sled_agent_port,
1498+
0,
1499+
0,
1500+
),
1501+
},
1502+
),
1503+
}
1504+
}
1505+
}

nexus/db-model/src/schema_versions.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::{collections::BTreeMap, sync::LazyLock};
1616
///
1717
/// This must be updated when you change the database schema. Refer to
1818
/// schema/crdb/README.adoc in the root of this repository for details.
19-
pub const SCHEMA_VERSION: Version = Version::new(178, 0, 0);
19+
pub const SCHEMA_VERSION: Version = Version::new(179, 0, 0);
2020

2121
/// List of all past database schema versions, in *reverse* order
2222
///
@@ -28,6 +28,7 @@ static KNOWN_VERSIONS: LazyLock<Vec<KnownVersion>> = LazyLock::new(|| {
2828
// | leaving the first copy as an example for the next person.
2929
// v
3030
// KnownVersion::new(next_int, "unique-dirname-with-the-sql-files"),
31+
KnownVersion::new(179, "add-pending-mgs-updates-host-phase-1"),
3132
KnownVersion::new(178, "change-lldp-management-ip-to-inet"),
3233
KnownVersion::new(177, "add-host-ereport-part-number"),
3334
KnownVersion::new(176, "audit-log"),

0 commit comments

Comments
 (0)