Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,7 @@ opt-level = 3
# tufaceous-artifact = { path = "../tufaceous/artifact" }
# tufaceous-brand-metadata = { path = "../tufaceous/brand-metadata" }
# tufaceous-lib = { path = "../tufaceous/lib" }
# Extra slash here to pretend to be a different source.

# [patch."https://github.com/oxidecomputer/typify"]
# typify = { path = "../typify/typify" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ created repo-1.0.0.zip for system version 1.0.0
> set target-release repo-1.0.0.zip
INFO extracting uploaded archive to <EXTRACTING_UPLOADED_ARCHIVE_TO_REDACTED>
INFO created directory to store extracted artifacts, path: <CREATED_DIRECTORY_TO_STORE_EXTRACTED_ARTIFACTS_PATH_REDACTED>
INFO added artifact, name: installinator_document, kind: installinator_document, version: 1.0.0, hash: c6ae866031d1183094c92cde9d9d1fd5f18356abc81a842ce31471b473fd5582, length: 367
INFO added artifact, name: SimGimletSp, kind: gimlet_sp, version: 1.0.0, hash: 7e6667e646ad001b54c8365a3d309c03f89c59102723d38d01697ee8079fe670, length: 747
INFO added artifact, name: fake-gimlet-rot, kind: gimlet_rot_image_a, version: 1.0.0, hash: 04e4a7fdb84acca92c8fd3235e26d64ea61bef8a5f98202589fd346989c5720a, length: 735
INFO added artifact, name: fake-gimlet-rot, kind: gimlet_rot_image_b, version: 1.0.0, hash: 04e4a7fdb84acca92c8fd3235e26d64ea61bef8a5f98202589fd346989c5720a, length: 735
Expand Down Expand Up @@ -818,6 +819,7 @@ set sled 98e6b7c2-2efa-41ca-b20a-0a4d61102fe6 inventory visibility: visible -> h
> set target-release repo-1.0.0.zip
INFO extracting uploaded archive to <EXTRACTING_UPLOADED_ARCHIVE_TO_REDACTED>
INFO created directory to store extracted artifacts, path: <CREATED_DIRECTORY_TO_STORE_EXTRACTED_ARTIFACTS_PATH_REDACTED>
INFO added artifact, name: installinator_document, kind: installinator_document, version: 1.0.0, hash: c6ae866031d1183094c92cde9d9d1fd5f18356abc81a842ce31471b473fd5582, length: 367
INFO added artifact, name: SimGimletSp, kind: gimlet_sp, version: 1.0.0, hash: 7e6667e646ad001b54c8365a3d309c03f89c59102723d38d01697ee8079fe670, length: 747
INFO added artifact, name: fake-gimlet-rot, kind: gimlet_rot_image_a, version: 1.0.0, hash: 04e4a7fdb84acca92c8fd3235e26d64ea61bef8a5f98202589fd346989c5720a, length: 735
INFO added artifact, name: fake-gimlet-rot, kind: gimlet_rot_image_b, version: 1.0.0, hash: 04e4a7fdb84acca92c8fd3235e26d64ea61bef8a5f98202589fd346989c5720a, length: 735
Expand Down Expand Up @@ -1018,6 +1020,7 @@ created repo-2.0.0.zip for system version 2.0.0
> sled-update-install-dataset serial2 --from-repo repo-2.0.0.zip
INFO extracting uploaded archive to <EXTRACTING_UPLOADED_ARCHIVE_TO_REDACTED>
INFO created directory to store extracted artifacts, path: <CREATED_DIRECTORY_TO_STORE_EXTRACTED_ARTIFACTS_PATH_REDACTED>
INFO added artifact, name: installinator_document, kind: installinator_document, version: 2.0.0, hash: 065b2b7cde09474c9a1bcf98a8f9c93129f617e074404c6aa76164f440a5627f, length: 367
INFO added artifact, name: fake-gimlet-sp, kind: gimlet_sp, version: 2.0.0, hash: ce1e98a8a9ae541654508f101d59a3ddeba3d28177f1d42d5614248eef0b820b, length: 751
INFO added artifact, name: fake-gimlet-rot, kind: gimlet_rot_image_a, version: 2.0.0, hash: e7047f500a5391e22cd8e6a8d3ae66c9d9de7a8d021e6e9a10e05bb6d554da77, length: 743
INFO added artifact, name: fake-gimlet-rot, kind: gimlet_rot_image_b, version: 2.0.0, hash: e7047f500a5391e22cd8e6a8d3ae66c9d9de7a8d021e6e9a10e05bb6d554da77, length: 743
Expand Down Expand Up @@ -1714,6 +1717,7 @@ external DNS:
> set target-release repo-2.0.0.zip
INFO extracting uploaded archive to <EXTRACTING_UPLOADED_ARCHIVE_TO_REDACTED>
INFO created directory to store extracted artifacts, path: <CREATED_DIRECTORY_TO_STORE_EXTRACTED_ARTIFACTS_PATH_REDACTED>
INFO added artifact, name: installinator_document, kind: installinator_document, version: 2.0.0, hash: 065b2b7cde09474c9a1bcf98a8f9c93129f617e074404c6aa76164f440a5627f, length: 367
INFO added artifact, name: fake-gimlet-sp, kind: gimlet_sp, version: 2.0.0, hash: ce1e98a8a9ae541654508f101d59a3ddeba3d28177f1d42d5614248eef0b820b, length: 751
INFO added artifact, name: fake-gimlet-rot, kind: gimlet_rot_image_a, version: 2.0.0, hash: e7047f500a5391e22cd8e6a8d3ae66c9d9de7a8d021e6e9a10e05bb6d554da77, length: 743
INFO added artifact, name: fake-gimlet-rot, kind: gimlet_rot_image_b, version: 2.0.0, hash: e7047f500a5391e22cd8e6a8d3ae66c9d9de7a8d021e6e9a10e05bb6d554da77, length: 743
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ created repo-2.0.0.zip for system version 2.0.0
> set target-release repo-1.0.0.zip
INFO extracting uploaded archive to <EXTRACTING_UPLOADED_ARCHIVE_TO_REDACTED>
INFO created directory to store extracted artifacts, path: <CREATED_DIRECTORY_TO_STORE_EXTRACTED_ARTIFACTS_PATH_REDACTED>
INFO added artifact, name: installinator_document, kind: installinator_document, version: 1.0.0, hash: c6ae866031d1183094c92cde9d9d1fd5f18356abc81a842ce31471b473fd5582, length: 367
INFO added artifact, name: SimGimletSp, kind: gimlet_sp, version: 1.0.0, hash: 7e6667e646ad001b54c8365a3d309c03f89c59102723d38d01697ee8079fe670, length: 747
INFO added artifact, name: fake-gimlet-rot, kind: gimlet_rot_image_a, version: 1.0.0, hash: 04e4a7fdb84acca92c8fd3235e26d64ea61bef8a5f98202589fd346989c5720a, length: 735
INFO added artifact, name: fake-gimlet-rot, kind: gimlet_rot_image_b, version: 1.0.0, hash: 04e4a7fdb84acca92c8fd3235e26d64ea61bef8a5f98202589fd346989c5720a, length: 735
Expand Down Expand Up @@ -103,6 +104,7 @@ sled aff6c093-197d-42c5-ad80-9f10ba051a34: install dataset updated: to target re
> sled-update-install-dataset serial4 --from-repo repo-2.0.0.zip
INFO extracting uploaded archive to <EXTRACTING_UPLOADED_ARCHIVE_TO_REDACTED>
INFO created directory to store extracted artifacts, path: <CREATED_DIRECTORY_TO_STORE_EXTRACTED_ARTIFACTS_PATH_REDACTED>
INFO added artifact, name: installinator_document, kind: installinator_document, version: 2.0.0, hash: 065b2b7cde09474c9a1bcf98a8f9c93129f617e074404c6aa76164f440a5627f, length: 367
INFO added artifact, name: fake-gimlet-sp, kind: gimlet_sp, version: 2.0.0, hash: ce1e98a8a9ae541654508f101d59a3ddeba3d28177f1d42d5614248eef0b820b, length: 751
INFO added artifact, name: fake-gimlet-rot, kind: gimlet_rot_image_a, version: 2.0.0, hash: e7047f500a5391e22cd8e6a8d3ae66c9d9de7a8d021e6e9a10e05bb6d554da77, length: 743
INFO added artifact, name: fake-gimlet-rot, kind: gimlet_rot_image_b, version: 2.0.0, hash: e7047f500a5391e22cd8e6a8d3ae66c9d9de7a8d021e6e9a10e05bb6d554da77, length: 743
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ created repo-1.0.0.zip for system version 1.0.0
> set target-release repo-1.0.0.zip
INFO extracting uploaded archive to <EXTRACTING_UPLOADED_ARCHIVE_TO_REDACTED>
INFO created directory to store extracted artifacts, path: <CREATED_DIRECTORY_TO_STORE_EXTRACTED_ARTIFACTS_PATH_REDACTED>
INFO added artifact, name: installinator_document, kind: installinator_document, version: 1.0.0, hash: c6ae866031d1183094c92cde9d9d1fd5f18356abc81a842ce31471b473fd5582, length: 367
INFO added artifact, name: SimGimletSp, kind: gimlet_sp, version: 1.0.0, hash: 7e6667e646ad001b54c8365a3d309c03f89c59102723d38d01697ee8079fe670, length: 747
INFO added artifact, name: fake-gimlet-rot, kind: gimlet_rot_image_a, version: 1.0.0, hash: 04e4a7fdb84acca92c8fd3235e26d64ea61bef8a5f98202589fd346989c5720a, length: 735
INFO added artifact, name: fake-gimlet-rot, kind: gimlet_rot_image_b, version: 1.0.0, hash: 04e4a7fdb84acca92c8fd3235e26d64ea61bef8a5f98202589fd346989c5720a, length: 735
Expand Down Expand Up @@ -70,6 +71,7 @@ internal DNS generations: 1
external DNS generations: 1
target number of Nexus instances: default
target release (generation 2): 1.0.0 (system-update-v1.0.0.zip)
artifact: c6ae866031d1183094c92cde9d9d1fd5f18356abc81a842ce31471b473fd5582 installinator_document (installinator_document version 1.0.0)
artifact: 7e6667e646ad001b54c8365a3d309c03f89c59102723d38d01697ee8079fe670 gimlet_sp (SimGimletSp version 1.0.0)
artifact: 04e4a7fdb84acca92c8fd3235e26d64ea61bef8a5f98202589fd346989c5720a gimlet_rot_image_a (fake-gimlet-rot version 1.0.0)
artifact: 04e4a7fdb84acca92c8fd3235e26d64ea61bef8a5f98202589fd346989c5720a gimlet_rot_image_b (fake-gimlet-rot version 1.0.0)
Expand Down Expand Up @@ -147,6 +149,7 @@ internal DNS generations: 1
external DNS generations: 1
target number of Nexus instances: default
target release (generation 2): 1.0.0 (system-update-v1.0.0.zip)
artifact: c6ae866031d1183094c92cde9d9d1fd5f18356abc81a842ce31471b473fd5582 installinator_document (installinator_document version 1.0.0)
artifact: 7e6667e646ad001b54c8365a3d309c03f89c59102723d38d01697ee8079fe670 gimlet_sp (SimGimletSp version 1.0.0)
artifact: 04e4a7fdb84acca92c8fd3235e26d64ea61bef8a5f98202589fd346989c5720a gimlet_rot_image_a (fake-gimlet-rot version 1.0.0)
artifact: 04e4a7fdb84acca92c8fd3235e26d64ea61bef8a5f98202589fd346989c5720a gimlet_rot_image_b (fake-gimlet-rot version 1.0.0)
Expand Down
1 change: 1 addition & 0 deletions dev-tools/releng/src/tuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ pub(crate) async fn build_tuf_repo(
manifest,
keys,
expiry,
true,
output_dir.join("repo.zip"),
)
.build()
Expand Down
3 changes: 3 additions & 0 deletions installinator-common/src/progress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ impl StepSpec for InstallinatorSpec {
)]
#[serde(rename_all = "snake_case")]
pub enum InstallinatorComponent {
/// The installinator document.
InstallinatorDocument,

/// The host phase 2 component.
HostPhase2,

Expand Down
98 changes: 86 additions & 12 deletions installinator/src/artifact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,19 @@ use installinator_common::EventReport;
use ipcc::{InstallinatorImageId, Ipcc};
use omicron_uuid_kinds::MupdateUuid;
use tokio::sync::mpsc;
use tufaceous_artifact::{ArtifactHash, ArtifactHashId};
use tufaceous_artifact::{
ArtifactHash, ArtifactHashId, ArtifactKind, KnownArtifactKind,
};

use crate::{errors::HttpError, fetch::FetchReceiver};

#[derive(Clone, Debug, Eq, PartialEq, Args)]
pub(crate) struct ArtifactIdOpts {
/// Retrieve artifact ID from IPCC
#[clap(long, required_unless_present_any = ["update_id", "host_phase_2", "control_plane"])]
#[clap(
long,
required_unless_present_any = ["update_id", "host_phase_2", "control_plane", "installinator_doc"]
)]
from_ipcc: bool,

#[clap(
Expand All @@ -31,31 +36,100 @@ pub(crate) struct ArtifactIdOpts {

#[clap(
long,
conflicts_with = "from_ipcc",
required_unless_present = "from_ipcc"
conflicts_with_all = ["from_ipcc", "installinator_doc"],
required_unless_present_any = ["from_ipcc", "installinator_doc"],
)]
host_phase_2: Option<ArtifactHash>,

#[clap(
long,
conflicts_with = "from_ipcc",
required_unless_present = "from_ipcc"
conflicts_with_all = ["from_ipcc", "installinator_doc"],
required_unless_present_any = ["from_ipcc", "installinator_doc"],
)]
control_plane: Option<ArtifactHash>,

#[clap(
long,
conflicts_with_all = ["from_ipcc", "host_phase_2", "control_plane"],
required_unless_present_any = ["from_ipcc", "host_phase_2", "control_plane"],
)]
installinator_doc: Option<ArtifactHash>,
}

impl ArtifactIdOpts {
pub(crate) fn resolve(&self) -> Result<InstallinatorImageId> {
pub(crate) fn resolve(&self) -> Result<LookupId> {
if self.from_ipcc {
let ipcc = Ipcc::new().context("error opening IPCC")?;
ipcc.installinator_image_id()
.context("error retrieving installinator image ID")
let image_id = ipcc
.installinator_image_id()
.context("error retrieving installinator image ID")?;
Ok(LookupId::from_image_id(&image_id))
} else {
let update_id = self.update_id.unwrap();
let host_phase_2 = self.host_phase_2.unwrap();
let control_plane = self.control_plane.unwrap();
let kind =
if let Some(installinator_doc_hash) = self.installinator_doc {
LookupIdKind::Document(installinator_doc_hash)
} else {
LookupIdKind::Hashes {
host_phase_2: self.host_phase_2.unwrap(),
control_plane: self.control_plane.unwrap(),
}
};

Ok(LookupId { update_id, kind })
}
}
}

/// Identifiers used by installinator to retrieve artifacts.
pub(crate) struct LookupId {
pub(crate) update_id: MupdateUuid,
pub(crate) kind: LookupIdKind,
}

impl LookupId {
fn from_image_id(image_id: &InstallinatorImageId) -> Self {
// This sentinel hash is used to indicate that the host phase 2 hash is
// actually the hash to the installinator document.
let kind = if image_id.control_plane == ArtifactHash([0; 32]) {
LookupIdKind::Document(image_id.host_phase_2)
} else {
LookupIdKind::Hashes {
host_phase_2: image_id.host_phase_2,
control_plane: image_id.control_plane,
}
};

Self { update_id: image_id.update_id, kind }
}
}

/// Either an installinator document hash, or host phase 2 and control plane
/// hashes.
pub(crate) enum LookupIdKind {
Document(ArtifactHash),
Hashes { host_phase_2: ArtifactHash, control_plane: ArtifactHash },
}

/// The host phase 2 and control plane hashes to download.
#[derive(Clone, Debug)]
pub(crate) struct ArtifactsToDownload {
pub(crate) host_phase_2: ArtifactHash,
pub(crate) control_plane: ArtifactHash,
}

impl ArtifactsToDownload {
pub(crate) fn host_phase_2_id(&self) -> ArtifactHashId {
ArtifactHashId {
kind: ArtifactKind::HOST_PHASE_2,
hash: self.host_phase_2,
}
}

Ok(InstallinatorImageId { update_id, host_phase_2, control_plane })
pub(crate) fn control_plane_id(&self) -> ArtifactHashId {
ArtifactHashId {
kind: KnownArtifactKind::ControlPlane.into(),
hash: self.control_plane,
Comment on lines +121 to +132
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of ArtifactKind vs KnownArtifactKind looks weirdly asymmetric

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it definitely is, though this just moves existing code.

}
}
}
Expand Down
Loading
Loading