Skip to content
Merged
28 changes: 7 additions & 21 deletions dev-tools/reconfigurator-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ use nexus_types::deployment::{
use nexus_types::deployment::{BlueprintZoneImageVersion, PendingMgsUpdate};
use nexus_types::external_api::views::SledPolicy;
use nexus_types::external_api::views::SledProvisionPolicy;
use nexus_types::inventory::SpType;
use omicron_common::address::REPO_DEPOT_PORT;
use omicron_common::api::external::Generation;
use omicron_common::api::external::Name;
Expand All @@ -56,11 +55,9 @@ use std::fmt::Write;
use std::io::IsTerminal;
use swrite::{SWrite, swriteln};
use tabled::Tabled;
use tufaceous_artifact::ArtifactHash;
use tufaceous_artifact::ArtifactVersion;
use tufaceous_artifact::ArtifactVersionError;
use tufaceous_artifact::{
ArtifactHash, ArtifactHashId, ArtifactKind, KnownArtifactKind,
};

mod log_capture;

Expand Down Expand Up @@ -919,27 +916,16 @@ fn cmd_blueprint_edit(
anyhow!("unknown baseboard serial: {serial:?}")
})?;

let (known_artifact_kind, details) = match component {
let details = match component {
SpUpdateComponent::Sp {
expected_active_version,
expected_inactive_version,
} => {
let known_artifact_kind = match sp.sp_type {
SpType::Sled => KnownArtifactKind::GimletSp,
SpType::Power => KnownArtifactKind::PscSp,
SpType::Switch => KnownArtifactKind::SwitchSp,
};
let details = PendingMgsUpdateDetails::Sp {
expected_active_version,
expected_inactive_version,
};
(known_artifact_kind, details)
}
} => PendingMgsUpdateDetails::Sp {
expected_active_version,
expected_inactive_version,
},
};

let artifact_kind = ArtifactKind::from_known(known_artifact_kind);
let artifact_hash_id =
ArtifactHashId { kind: artifact_kind, hash: artifact_hash };
let artifact_version = ArtifactVersion::new(version)
.context("parsing artifact version")?;

Expand All @@ -948,7 +934,7 @@ fn cmd_blueprint_edit(
sp_type: sp.sp_type,
slot_id: u32::from(sp.sp_slot),
details,
artifact_hash_id,
artifact_hash,
artifact_version,
};

Expand Down

Large diffs are not rendered by default.

21 changes: 3 additions & 18 deletions dev-tools/reconfigurator-sp-updater/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ use std::sync::Arc;
use std::time::Duration;
use tokio::sync::watch;
use tufaceous_artifact::ArtifactHash;
use tufaceous_artifact::ArtifactHashId;
use tufaceous_artifact::ArtifactKind;
use tufaceous_artifact::ArtifactVersion;
use tufaceous_artifact::KnownArtifactKind;

#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
Expand Down Expand Up @@ -309,7 +306,7 @@ fn cmd_config(
update.sp_type,
update.slot_id,
)?;
writeln!(&mut s, " artifact hash: {}", update.artifact_hash_id,)?;
writeln!(&mut s, " artifact hash: {}", update.artifact_hash)?;
writeln!(
&mut s,
" user-provided artifact version: {}",
Expand Down Expand Up @@ -357,11 +354,7 @@ fn cmd_status(
)?;
writeln!(&mut s, " attempt#: {}", r.nattempts_done)?;
writeln!(&mut s, " version: {}", r.request.artifact_version)?;
writeln!(
&mut s,
" hash: {}",
r.request.artifact_hash_id.hash
)?;
writeln!(&mut s, " hash: {}", r.request.artifact_hash,)?;
writeln!(&mut s, " result: {:?}", r.result)?;
}

Expand Down Expand Up @@ -424,14 +417,6 @@ fn cmd_set(
) -> anyhow::Result<Option<String>> {
let serial = &args.serial;
let info = updater_state.inventory.info_for_serial(serial)?;
let known_artifact_kind = match (&args.component, info.sp_type) {
(Component::Sp { .. }, SpType::Sled) => KnownArtifactKind::GimletSp,
(Component::Sp { .. }, SpType::Power) => KnownArtifactKind::PscSp,
(Component::Sp { .. }, SpType::Switch) => KnownArtifactKind::SwitchSp,
};
let artifact_kind = ArtifactKind::from_known(known_artifact_kind);
let artifact_hash_id =
ArtifactHashId { kind: artifact_kind, hash: args.artifact_hash };
let request = PendingMgsUpdate {
baseboard_id: info.baseboard_id.clone(),
sp_type: info.sp_type,
Expand All @@ -445,7 +430,7 @@ fn cmd_set(
expected_inactive_version,
},
},
artifact_hash_id,
artifact_hash: args.artifact_hash,
artifact_version: ArtifactVersion::new(args.version)
.context("parsing artifact version")?,
};
Expand Down
3 changes: 1 addition & 2 deletions nexus/mgs-updates/src/driver_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ pub(crate) async fn apply_update(
};

// Obtain the contents of the artifact that we need.
let data =
artifacts.artifact_contents(&update.artifact_hash_id.hash).await?;
let data = artifacts.artifact_contents(&update.artifact_hash).await?;
debug!(log, "loaded artifact contents");

// Check the live state first to see if:
Expand Down
20 changes: 4 additions & 16 deletions nexus/types/src/deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ use std::net::Ipv6Addr;
use std::net::SocketAddrV6;
use strum::EnumIter;
use tufaceous_artifact::ArtifactHash;
use tufaceous_artifact::ArtifactHashId;
use tufaceous_artifact::ArtifactVersion;
use tufaceous_artifact::ArtifactVersionError;

Expand Down Expand Up @@ -1193,7 +1192,7 @@ pub struct PendingMgsUpdate {

/// which artifact to apply to this device
/// (implies which component is being updated)
pub artifact_hash_id: ArtifactHashId,
pub artifact_hash: ArtifactHash,
pub artifact_version: ArtifactVersion,
}

Expand All @@ -1208,13 +1207,9 @@ impl slog::KV for PendingMgsUpdate {
.emit_str(Key::from("sp_type"), &format!("{:?}", self.sp_type))?;
serializer.emit_u32(Key::from("sp_slot"), self.slot_id)?;
slog::KV::serialize(&self.details, record, serializer)?;
serializer.emit_str(
Key::from("artifact_kind"),
&self.artifact_hash_id.kind.as_str(),
)?;
serializer.emit_str(
Key::from("artifact_hash"),
&self.artifact_hash_id.hash.to_string(),
&self.artifact_hash.to_string(),
)
}
}
Expand All @@ -1233,8 +1228,7 @@ impl PendingMgsUpdate {
self.slot_id.to_string(),
self.baseboard_id.part_number.clone(),
self.baseboard_id.serial_number.clone(),
self.artifact_hash_id.kind.to_string(),
self.artifact_hash_id.hash.to_string(),
self.artifact_hash.to_string(),
self.artifact_version.to_string(),
format!("{:?}", self.details),
]
Expand Down Expand Up @@ -1688,9 +1682,6 @@ mod test {
use crate::inventory::BaseboardId;
use gateway_client::types::SpType;
use std::sync::Arc;
use tufaceous_artifact::ArtifactHashId;
use tufaceous_artifact::ArtifactKind;
use tufaceous_artifact::KnownArtifactKind;

#[test]
fn test_serialize_pending_mgs_updates() {
Expand Down Expand Up @@ -1718,10 +1709,7 @@ mod test {
"1.0.36".parse().unwrap(),
),
},
artifact_hash_id: ArtifactHashId {
kind: ArtifactKind::from_known(KnownArtifactKind::GimletSp),
hash: "47266ede81e13f5f1e36623ea8dd963842606b783397e4809a9a5f0bda0f8170".parse().unwrap(),
},
artifact_hash: "47266ede81e13f5f1e36623ea8dd963842606b783397e4809a9a5f0bda0f8170".parse().unwrap(),
artifact_version: "1.0.34".parse().unwrap(),
};
pending_mgs_updates.insert(update);
Expand Down
11 changes: 2 additions & 9 deletions nexus/types/src/deployment/blueprint_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1633,14 +1633,8 @@ impl<'a> BpDiffPendingMgsUpdates<'a> {
&u1.baseboard_id.serial_number,
&u2.baseboard_id.serial_number,
);
let artifact_kind = BpTableColumn::new(
&u1.artifact_hash_id.kind,
&u2.artifact_hash_id.kind,
);
let artifact_hash = BpTableColumn::new(
&u1.artifact_hash_id.hash,
&u2.artifact_hash_id.hash,
);
let artifact_hash =
BpTableColumn::new(&u1.artifact_hash, &u2.artifact_hash);
let artifact_version =
BpTableColumn::new(&u1.artifact_version, &u2.artifact_version);
let details = if u1.details != u2.details {
Expand All @@ -1658,7 +1652,6 @@ impl<'a> BpDiffPendingMgsUpdates<'a> {
slot_id,
part_number,
serial_number,
artifact_kind,
artifact_hash,
artifact_version,
details,
Expand Down
1 change: 0 additions & 1 deletion nexus/types/src/deployment/blueprint_display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,6 @@ impl BpTableSchema for BpPendingMgsUpdates {
"slot",
"part_number",
"serial_number",
"artifact_kind",
"artifact_hash",
"artifact_version",
"details",
Expand Down
30 changes: 4 additions & 26 deletions openapi/nexus-internal.json
Original file line number Diff line number Diff line change
Expand Up @@ -1620,25 +1620,6 @@
}
]
},
"ArtifactHashId": {
"description": "A hash-based identifier for an artifact or deployment unit: the kind and hash.",
"type": "object",
"properties": {
"hash": {
"description": "The hash of the artifact.",
"type": "string",
"format": "hex string (32 bytes)"
},
"kind": {
"description": "The kind of artifact this is.",
"type": "string"
}
},
"required": [
"hash",
"kind"
]
},
"ArtifactVersion": {
"description": "An artifact version.\n\nThis is a freeform identifier with some basic validation. It may be the serialized form of a semver version, or a custom identifier that uses the same character set as a semver, plus `_`.\n\nThe exact pattern accepted is `^[a-zA-Z0-9._+-]{1,63}$`.\n\n# Ord implementation\n\n`ArtifactVersion`s are not intended to be sorted, just compared for equality. `ArtifactVersion` implements `Ord` only for storage within sorted collections.",
"type": "string",
Expand Down Expand Up @@ -4880,13 +4861,10 @@
"PendingMgsUpdate": {
"type": "object",
"properties": {
"artifact_hash_id": {
"artifact_hash": {
"description": "which artifact to apply to this device (implies which component is being updated)",
"allOf": [
{
"$ref": "#/components/schemas/ArtifactHashId"
}
]
"type": "string",
"format": "hex string (32 bytes)"
},
"artifact_version": {
"$ref": "#/components/schemas/ArtifactVersion"
Expand Down Expand Up @@ -4923,7 +4901,7 @@
}
},
"required": [
"artifact_hash_id",
"artifact_hash",
"artifact_version",
"baseboard_id",
"details",
Expand Down
Loading