Skip to content

Commit 39672a4

Browse files
authored
[reconfigurator] database support for PendingMgsUpdate for RoT (#8588)
Equivalent of #8291 for RoT
1 parent 772a685 commit 39672a4

File tree

8 files changed

+549
-168
lines changed

8 files changed

+549
-168
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nexus/db-model/src/deployment.rs

Lines changed: 70 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//! Types for representing the deployed software and configuration in the
66
//! database
77
8-
use crate::inventory::{SpMgsSlot, SpType, ZoneType};
8+
use crate::inventory::{HwRotSlot, SpMgsSlot, SpType, ZoneType};
99
use crate::omicron_zone_config::{self, OmicronZoneNic};
1010
use crate::typed_uuid::DbTypedUuid;
1111
use crate::{
@@ -22,8 +22,8 @@ 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_sp, bp_sled_metadata,
26-
bp_target,
25+
bp_oximeter_read_policy, bp_pending_mgs_update_rot,
26+
bp_pending_mgs_update_sp, bp_sled_metadata, bp_target,
2727
};
2828
use nexus_sled_agent_shared::inventory::OmicronZoneDataset;
2929
use nexus_types::deployment::BlueprintHostPhase2DesiredContents;
@@ -36,6 +36,7 @@ use nexus_types::deployment::BlueprintZoneDisposition;
3636
use nexus_types::deployment::BlueprintZoneType;
3737
use nexus_types::deployment::ClickhouseClusterConfig;
3838
use nexus_types::deployment::CockroachDbPreserveDowngrade;
39+
use nexus_types::deployment::ExpectedActiveRotSlot;
3940
use nexus_types::deployment::PendingMgsUpdate;
4041
use nexus_types::deployment::PendingMgsUpdateDetails;
4142
use nexus_types::deployment::{
@@ -1302,6 +1303,14 @@ impl BpOximeterReadPolicy {
13021303
}
13031304
}
13041305

1306+
pub trait BpPendingMgsUpdateComponent {
1307+
/// Converts a BpMgsUpdate into a PendingMgsUpdate
1308+
fn into_generic(self, baseboard_id: Arc<BaseboardId>) -> PendingMgsUpdate;
1309+
1310+
/// Retrieves the baseboard ID
1311+
fn hw_baseboard_id(&self) -> &Uuid;
1312+
}
1313+
13051314
#[derive(Queryable, Clone, Debug, Selectable, Insertable)]
13061315
#[diesel(table_name = bp_pending_mgs_update_sp)]
13071316
pub struct BpPendingMgsUpdateSp {
@@ -1315,11 +1324,12 @@ pub struct BpPendingMgsUpdateSp {
13151324
pub expected_inactive_version: Option<DbArtifactVersion>,
13161325
}
13171326

1318-
impl BpPendingMgsUpdateSp {
1319-
pub fn into_generic(
1320-
self,
1321-
baseboard_id: Arc<BaseboardId>,
1322-
) -> PendingMgsUpdate {
1327+
impl BpPendingMgsUpdateComponent for BpPendingMgsUpdateSp {
1328+
fn hw_baseboard_id(&self) -> &Uuid {
1329+
&self.hw_baseboard_id
1330+
}
1331+
1332+
fn into_generic(self, baseboard_id: Arc<BaseboardId>) -> PendingMgsUpdate {
13231333
PendingMgsUpdate {
13241334
baseboard_id,
13251335
sp_type: self.sp_type.into(),
@@ -1338,3 +1348,55 @@ impl BpPendingMgsUpdateSp {
13381348
}
13391349
}
13401350
}
1351+
1352+
#[derive(Queryable, Clone, Debug, Selectable, Insertable)]
1353+
#[diesel(table_name = bp_pending_mgs_update_rot)]
1354+
pub struct BpPendingMgsUpdateRot {
1355+
pub blueprint_id: DbTypedUuid<BlueprintKind>,
1356+
pub hw_baseboard_id: Uuid,
1357+
pub sp_type: SpType,
1358+
pub sp_slot: SpMgsSlot,
1359+
pub artifact_sha256: ArtifactHash,
1360+
pub artifact_version: DbArtifactVersion,
1361+
pub expected_active_slot: HwRotSlot,
1362+
pub expected_active_version: DbArtifactVersion,
1363+
pub expected_inactive_version: Option<DbArtifactVersion>,
1364+
pub expected_persistent_boot_preference: HwRotSlot,
1365+
pub expected_pending_persistent_boot_preference: Option<HwRotSlot>,
1366+
pub expected_transient_boot_preference: Option<HwRotSlot>,
1367+
}
1368+
1369+
impl BpPendingMgsUpdateComponent for BpPendingMgsUpdateRot {
1370+
fn hw_baseboard_id(&self) -> &Uuid {
1371+
&self.hw_baseboard_id
1372+
}
1373+
1374+
fn into_generic(self, baseboard_id: Arc<BaseboardId>) -> PendingMgsUpdate {
1375+
PendingMgsUpdate {
1376+
baseboard_id,
1377+
sp_type: self.sp_type.into(),
1378+
slot_id: **self.sp_slot,
1379+
artifact_hash: self.artifact_sha256.into(),
1380+
artifact_version: (*self.artifact_version).clone(),
1381+
details: PendingMgsUpdateDetails::Rot {
1382+
expected_active_slot: ExpectedActiveRotSlot {
1383+
slot: self.expected_active_slot.into(),
1384+
version: (*self.expected_active_version).clone(),
1385+
},
1386+
expected_inactive_version: self
1387+
.expected_inactive_version
1388+
.map(|v| ExpectedVersion::Version(v.into()))
1389+
.unwrap_or(ExpectedVersion::NoValidVersion),
1390+
expected_persistent_boot_preference: self
1391+
.expected_persistent_boot_preference
1392+
.into(),
1393+
expected_pending_persistent_boot_preference: self
1394+
.expected_pending_persistent_boot_preference
1395+
.map(|s| s.into()),
1396+
expected_transient_boot_preference: self
1397+
.expected_transient_boot_preference
1398+
.map(|s| s.into()),
1399+
},
1400+
}
1401+
}
1402+
}

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(166, 0, 0);
19+
pub const SCHEMA_VERSION: Version = Version::new(167, 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(167, "add-pending-mgs-updates-rot"),
3132
KnownVersion::new(166, "bundle-user-comment"),
3233
KnownVersion::new(165, "route-config-rib-priority"),
3334
KnownVersion::new(164, "fix-leaked-bp-oximeter-read-policy-rows"),

nexus/db-queries/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ criterion.workspace = true
8888
expectorate.workspace = true
8989
hyper-rustls.workspace = true
9090
gateway-client.workspace = true
91+
gateway-types.workspace = true
9192
illumos-utils.workspace = true
9293
internal-dns-resolver.workspace = true
9394
itertools.workspace = true

0 commit comments

Comments
 (0)