Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dev-tools/reconfigurator-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1290,7 +1290,7 @@ fn cmd_blueprint_edit(
let update = PendingMgsUpdate {
baseboard_id: baseboard_id.clone(),
sp_type: sp.sp_type,
slot_id: u32::from(sp.sp_slot),
slot_id: sp.sp_slot,
details,
artifact_hash,
artifact_version,
Expand Down
20 changes: 11 additions & 9 deletions dev-tools/reconfigurator-sp-updater/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ impl Inventory {
struct SpInfo {
baseboard_id: Arc<BaseboardId>,
sp_type: SpType,
sp_slot_id: u32,
sp_slot_id: u16,
}

impl Inventory {
Expand All @@ -214,16 +214,21 @@ impl Inventory {
}),
)
.then(async move |sp_id| {
let sp_slot = u16::try_from(sp_id.slot).with_context(|| {
format!("sp slot number is out of range: {sp_id:?}")
})?;
c.sp_get(sp_id.type_, sp_id.slot)
.await
.with_context(|| format!("fetching info about SP {:?}", sp_id))
.map(|s| (sp_id, s))
.map(|s| (sp_id.type_, sp_slot, s))
})
.collect::<Vec<Result<_, _>>>()
.await
.into_iter()
.filter_map(|r| match r {
Ok((sp_id, v)) => Some((sp_id, v.into_inner())),
Ok((sp_type, sp_slot, v)) => {
Some((sp_type, sp_slot, v.into_inner()))
}
Err(error) => {
warn!(
log,
Expand All @@ -237,17 +242,14 @@ impl Inventory {

let sps_by_serial = sp_infos
.into_iter()
.map(|(sp_id, sp_state)| {
.map(|(sp_type, sp_slot, sp_state)| {
let baseboard_id = Arc::new(BaseboardId {
serial_number: sp_state.serial_number,
part_number: sp_state.model,
});
let serial_number = baseboard_id.serial_number.clone();
let sp_info = SpInfo {
baseboard_id,
sp_type: sp_id.type_,
sp_slot_id: sp_id.slot,
};
let sp_info =
SpInfo { baseboard_id, sp_type, sp_slot_id: sp_slot };
(serial_number, sp_info)
})
.collect();
Expand Down
53 changes: 48 additions & 5 deletions nexus/db-model/src/deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
//! Types for representing the deployed software and configuration in the
//! database

use crate::inventory::ZoneType;
use crate::inventory::{SpMgsSlot, SpType, ZoneType};
use crate::omicron_zone_config::{self, OmicronZoneNic};
use crate::typed_uuid::DbTypedUuid;
use crate::{
ArtifactHash, ByteCount, DbOximeterReadMode, Generation, MacAddr, Name,
SledState, SqlU8, SqlU16, SqlU32, TufArtifact, impl_enum_type, ipv6,
ArtifactHash, ByteCount, DbArtifactVersion, DbOximeterReadMode, Generation,
MacAddr, Name, SledState, SqlU8, SqlU16, SqlU32, TufArtifact,
impl_enum_type, ipv6,
};
use anyhow::{Context, Result, anyhow, bail};
use chrono::{DateTime, Utc};
Expand All @@ -21,10 +22,10 @@ use nexus_db_schema::schema::{
bp_clickhouse_keeper_zone_id_to_node_id,
bp_clickhouse_server_zone_id_to_node_id, bp_omicron_dataset,
bp_omicron_physical_disk, bp_omicron_zone, bp_omicron_zone_nic,
bp_oximeter_read_policy, bp_sled_metadata, bp_target,
bp_oximeter_read_policy, bp_pending_mgs_update_sp, bp_sled_metadata,
bp_target,
};
use nexus_sled_agent_shared::inventory::OmicronZoneDataset;
use nexus_types::deployment::BlueprintDatasetDisposition;
use nexus_types::deployment::BlueprintPhysicalDiskConfig;
use nexus_types::deployment::BlueprintPhysicalDiskDisposition;
use nexus_types::deployment::BlueprintTarget;
Expand All @@ -33,14 +34,18 @@ use nexus_types::deployment::BlueprintZoneDisposition;
use nexus_types::deployment::BlueprintZoneType;
use nexus_types::deployment::ClickhouseClusterConfig;
use nexus_types::deployment::CockroachDbPreserveDowngrade;
use nexus_types::deployment::PendingMgsUpdate;
use nexus_types::deployment::PendingMgsUpdateDetails;
use nexus_types::deployment::{
BlueprintDatasetConfig, BlueprintZoneImageVersion, OximeterReadMode,
};
use nexus_types::deployment::{BlueprintDatasetDisposition, ExpectedVersion};
use nexus_types::deployment::{BlueprintZoneImageSource, blueprint_zone_type};
use nexus_types::deployment::{
OmicronZoneExternalFloatingAddr, OmicronZoneExternalFloatingIp,
OmicronZoneExternalSnatIp,
};
use nexus_types::inventory::BaseboardId;
use omicron_common::api::internal::shared::NetworkInterface;
use omicron_common::disk::DiskIdentity;
use omicron_common::zpool_name::ZpoolName;
Expand All @@ -50,6 +55,7 @@ use omicron_uuid_kinds::{
PhysicalDiskKind, SledKind, SledUuid, ZpoolKind, ZpoolUuid,
};
use std::net::{IpAddr, SocketAddrV6};
use std::sync::Arc;
use uuid::Uuid;

/// See [`nexus_types::deployment::Blueprint`].
Expand Down Expand Up @@ -1245,3 +1251,40 @@ impl BpOximeterReadPolicy {
}
}
}

#[derive(Queryable, Clone, Debug, Selectable, Insertable)]
#[diesel(table_name = bp_pending_mgs_update_sp)]
pub struct BpPendingMgsUpdateSp {
pub blueprint_id: DbTypedUuid<BlueprintKind>,
pub hw_baseboard_id: Uuid,
pub sp_type: SpType,
pub sp_slot: SpMgsSlot,
pub artifact_sha256: ArtifactHash,
pub artifact_version: DbArtifactVersion,
pub expected_active_version: DbArtifactVersion,
pub expected_inactive_version: Option<DbArtifactVersion>,
}

impl BpPendingMgsUpdateSp {
pub fn into_generic(
self,
baseboard_id: Arc<BaseboardId>,
) -> PendingMgsUpdate {
PendingMgsUpdate {
baseboard_id,
sp_type: self.sp_type.into(),
slot_id: **self.sp_slot,
artifact_hash: self.artifact_sha256.into(),
artifact_version: (*self.artifact_version).clone(),
details: PendingMgsUpdateDetails::Sp {
expected_active_version: (*self.expected_active_version)
.clone(),
expected_inactive_version: match self.expected_inactive_version
{
Some(v) => ExpectedVersion::Version((*v).clone()),
None => ExpectedVersion::NoValidVersion,
},
},
}
}
}
1 change: 1 addition & 0 deletions nexus/db-model/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ pub use switch_interface::*;
pub use switch_port::*;
pub use target_release::*;
pub use tuf_repo::*;
pub use typed_uuid::DbTypedUuid;
pub use typed_uuid::to_db_typed_uuid;
pub use upstairs_repair::*;
pub use user_builtin::*;
Expand Down
3 changes: 2 additions & 1 deletion nexus/db-model/src/schema_versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::{collections::BTreeMap, sync::LazyLock};
///
/// This must be updated when you change the database schema. Refer to
/// schema/crdb/README.adoc in the root of this repository for details.
pub const SCHEMA_VERSION: Version = Version::new(150, 0, 0);
pub const SCHEMA_VERSION: Version = Version::new(151, 0, 0);

/// List of all past database schema versions, in *reverse* order
///
Expand All @@ -28,6 +28,7 @@ static KNOWN_VERSIONS: LazyLock<Vec<KnownVersion>> = LazyLock::new(|| {
// | leaving the first copy as an example for the next person.
// v
// KnownVersion::new(next_int, "unique-dirname-with-the-sql-files"),
KnownVersion::new(151, "add-pending-mgs-updates"),
KnownVersion::new(150, "add-last-reconciliation-orphaned-datasets"),
KnownVersion::new(149, "bp-add-target-release-min-gen"),
KnownVersion::new(148, "clean-misplaced-m2s"),
Expand Down
Loading
Loading