Skip to content

Commit 8d0d56b

Browse files
authored
[7/n] [installinator] write out zone hashes to a new zones.json file (#8155)
Part of RFD 556. In upcoming work, sled-agent will check these hashes at boot time, and mark an error if there's a mismatch. The stack was [tested on a racklette](#8237 (comment)).
1 parent 0439558 commit 8d0d56b

File tree

13 files changed

+234
-25
lines changed

13 files changed

+234
-25
lines changed

Cargo.lock

Lines changed: 12 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ hyper = "1.6.0"
473473
hyper-util = "0.1.11"
474474
hyper-rustls = "0.26.0"
475475
hyper-staticfile = "0.10.1"
476-
iddqd = { version = "0.3.0", features = ["daft", "serde"] }
476+
iddqd = { version = "0.3.5", features = ["daft", "serde"] }
477477
id-map = { path = "id-map" }
478478
illumos-utils = { path = "illumos-utils" }
479479
iana-time-zone = "0.1.63"

common/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ dropshot.workspace = true
2525
futures.workspace = true
2626
hex.workspace = true
2727
http.workspace = true
28+
iddqd.workspace = true
2829
id-map.workspace = true
2930
ipnetwork.workspace = true
3031
lldp_protocol.workspace = true

common/src/update/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
mod artifact_id;
66
mod mupdate_override;
7+
mod zone_manifest;
78

89
pub use artifact_id::*;
910
pub use mupdate_override::*;
11+
pub use zone_manifest::*;

common/src/update/mupdate_override.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ pub struct MupdateOverrideInfo {
2020
pub mupdate_uuid: MupdateOverrideUuid,
2121

2222
/// Artifact hashes written out to the install dataset.
23+
///
24+
/// Currently includes the host phase 2 and composite control plane
25+
/// artifacts.
2326
pub hash_ids: BTreeSet<ArtifactHashId>,
2427
}
2528

common/src/update/zone_manifest.rs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// This Source Code Form is subject to the terms of the Mozilla Public
2+
// License, v. 2.0. If a copy of the MPL was not distributed with this
3+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
5+
use iddqd::{IdOrdItem, IdOrdMap, id_upcast};
6+
use omicron_uuid_kinds::MupdateUuid;
7+
use serde::{Deserialize, Serialize};
8+
use tufaceous_artifact::ArtifactHash;
9+
10+
/// Describes the set of Omicron zones written out into an install dataset.
11+
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
12+
pub struct OmicronZoneManifest {
13+
/// The UUID of the mupdate which created this manifest. Intended primarily
14+
/// for checking equality.
15+
pub mupdate_id: MupdateUuid,
16+
17+
/// Omicron zone file names and hashes.
18+
pub zones: IdOrdMap<OmicronZoneFileMetadata>,
19+
}
20+
21+
impl OmicronZoneManifest {
22+
/// The name of the file.
23+
pub const FILE_NAME: &str = "zones.json";
24+
}
25+
26+
/// Information about an Omicron zone file written out to the install dataset.
27+
///
28+
/// Part of [`OmicronZoneManifest`].
29+
#[derive(
30+
Clone, Debug, Eq, Ord, PartialEq, PartialOrd, Deserialize, Serialize,
31+
)]
32+
pub struct OmicronZoneFileMetadata {
33+
/// The file name.
34+
pub file_name: String,
35+
36+
/// The file size.
37+
pub file_size: u64,
38+
39+
/// The hash of the file.
40+
pub hash: ArtifactHash,
41+
}
42+
43+
impl IdOrdItem for OmicronZoneFileMetadata {
44+
type Key<'a> = &'a str;
45+
46+
#[inline]
47+
fn key(&self) -> Self::Key<'_> {
48+
&self.file_name
49+
}
50+
51+
id_upcast!();
52+
}

installinator-common/src/progress.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,9 @@ pub enum ControlPlaneZonesStepId {
297297
/// Writing the MUPdate override file.
298298
MupdateOverride,
299299

300+
/// Writing the zone manifest.
301+
ZoneManifest,
302+
300303
/// Syncing writes to disk.
301304
Fsync,
302305

installinator/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ display-error-chain.workspace = true
2121
futures.workspace = true
2222
hex.workspace = true
2323
http.workspace = true
24+
iddqd.workspace = true
2425
illumos-utils.workspace = true
2526
installinator-client.workspace = true
2627
installinator-common.workspace = true

installinator/src/dispatch.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ impl InstallOpts {
351351
control_plane_zones.into_value(cx.token()).await;
352352

353353
let mut writer = ArtifactWriter::new(
354+
image_id.update_id,
354355
&host_2_phase_id_2,
355356
&host_phase_2_artifact.artifact,
356357
&control_plane_id_2,

0 commit comments

Comments
 (0)