Skip to content

Commit 06aab1e

Browse files
committed
Add Measurement Corpus artifact
This will be installed for wicket via the installinator document. Skip installing anything for the moment.
1 parent 61ad056 commit 06aab1e

File tree

10 files changed

+253
-121
lines changed

10 files changed

+253
-121
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,7 @@ rand_distr = "0.4.3"
647647
rand_seeder = "0.3.0"
648648
range-requests = { path = "range-requests" }
649649
ratatui = "0.29.0"
650+
rats-corim = { git = "https://github.com/oxidecomputer/rats-corim.git", branch = "main" }
650651
rayon = "1.10"
651652
rcgen = "0.12.1"
652653
reconfigurator-cli = { path = "dev-tools/reconfigurator-cli" }
@@ -747,10 +748,10 @@ toml_edit = "0.22.27"
747748
tough = { version = "0.20.0", features = [ "http" ] }
748749
transceiver-controller = { git = "https://github.com/oxidecomputer/transceiver-control", features = [ "api-traits" ] }
749750
trybuild = "1.0.106"
750-
tufaceous = { git = "https://github.com/oxidecomputer/tufaceous", branch = "main" }
751-
tufaceous-artifact = { git = "https://github.com/oxidecomputer/tufaceous", branch = "main", features = ["proptest", "schemars"] }
752-
tufaceous-brand-metadata = { git = "https://github.com/oxidecomputer/tufaceous", branch = "main" }
753-
tufaceous-lib = { git = "https://github.com/oxidecomputer/tufaceous", branch = "main" }
751+
tufaceous = { git = "https://github.com/oxidecomputer/tufaceous", branch = "measurement_corpus_take_2" }
752+
tufaceous-artifact = { git = "https://github.com/oxidecomputer/tufaceous", branch = "measurement_corpus_take_2", features = ["proptest", "schemars"] }
753+
tufaceous-brand-metadata = { git = "https://github.com/oxidecomputer/tufaceous", branch = "measurement_corpus_take_2" }
754+
tufaceous-lib = { git = "https://github.com/oxidecomputer/tufaceous", branch = "measurement_corpus_take_2" }
754755
tui-tree-widget = "0.23.1"
755756
typed-rng = { path = "typed-rng" }
756757
typify = "0.3.0"

dev-tools/releng/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ hex.workspace = true
1717
omicron-pins.workspace = true
1818
omicron-workspace-hack.workspace = true
1919
omicron-zone-package.workspace = true
20+
rats-corim.workspace = true
2021
reqwest.workspace = true
2122
semver.workspace = true
2223
serde.workspace = true

dev-tools/releng/src/hubris.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@ pub(crate) async fn fetch_hubris_artifacts(
3838

3939
fs::create_dir_all(&output_dir).await?;
4040

41+
// We need to remove our old downloaded corpus to make sure nothing else
42+
// gets added to the repo unexpectedly. This should only really be a
43+
// issue with local builds
44+
if std::fs::exists(&output_dir.join("measurement_corpus"))
45+
.context("failed to check `measurement_corpus`")?
46+
{
47+
std::fs::remove_dir_all(&output_dir.join("measurement_corpus"))
48+
.context("failed to remove `measurement_corpus")?;
49+
}
50+
fs::create_dir_all(&output_dir.join("measurement_corpus"))
51+
.await
52+
.context("Failed to create `measurement_corpus`")?;
53+
4154
// This could be parallelized with FuturesUnordered but in practice this
4255
// takes less time than OS builds.
4356

@@ -106,6 +119,22 @@ pub(crate) async fn fetch_hubris_artifacts(
106119
}
107120
}
108121
}
122+
if let Some(corpus) = hash_manifest.corpus {
123+
let hash = match corpus {
124+
Source::File(file) => file.hash,
125+
_ => anyhow::bail!(
126+
"Unexpected file type: should be a single file, not an RoT"
127+
),
128+
};
129+
let data =
130+
fetch_hash(&logger, base_url, &client, &hash).await?;
131+
fs::write(
132+
output_dir.join("measurement_corpus").join(hash),
133+
data,
134+
)
135+
.await
136+
.context("failed to write file {hash}")?;
137+
}
109138
}
110139
}
111140

@@ -160,6 +189,9 @@ async fn fetch_hash(
160189
struct Manifest {
161190
#[serde(rename = "artifact")]
162191
artifacts: HashMap<KnownArtifactKind, Vec<Artifact>>,
192+
// Add a default for backwards compatibility
193+
#[serde(rename = "measurement_corpus")]
194+
corpus: Option<Source>,
163195
}
164196

165197
#[derive(Deserialize)]

dev-tools/releng/src/tuf.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,46 @@ pub(crate) async fn build_tuf_repo(
7676
}
7777
}
7878

79+
let mut measurement_corpus = vec![];
80+
81+
for entry in std::fs::read_dir(
82+
output_dir.join("hubris-staging").join("measurement_corpus"),
83+
)
84+
.context("failed to read `hubris-staging/measurement_corpus")?
85+
{
86+
let entry = entry?;
87+
88+
let corim = rats_corim::Corim::from_file(entry.path())?;
89+
90+
measurement_corpus.push(DeserializedArtifactData {
91+
name: format!("staging-{}", corim.id),
92+
version: ArtifactVersion::new(corim.get_version()?.clone())?,
93+
source: DeserializedArtifactSource::File {
94+
path: Utf8PathBuf::from_path_buf(entry.path()).unwrap(),
95+
},
96+
});
97+
}
98+
99+
for entry in std::fs::read_dir(
100+
output_dir.join("hubris-production").join("measurement_corpus"),
101+
)
102+
.context("failed to read `hubris-production/measurement_corpus")?
103+
{
104+
let entry = entry?;
105+
let corim = rats_corim::Corim::from_file(entry.path())?;
106+
measurement_corpus.push(DeserializedArtifactData {
107+
name: format!("production-{}", corim.id),
108+
version: ArtifactVersion::new(corim.get_version()?.clone())?,
109+
source: DeserializedArtifactSource::File {
110+
path: Utf8PathBuf::from_path_buf(entry.path()).unwrap(),
111+
},
112+
});
113+
}
114+
115+
manifest
116+
.artifacts
117+
.insert(KnownArtifactKind::MeasurementCorpus, measurement_corpus);
118+
79119
// Add the OS images.
80120
manifest.artifacts.insert(
81121
KnownArtifactKind::Host,
@@ -115,6 +155,7 @@ pub(crate) async fn build_tuf_repo(
115155
.join(format!("{}.tar.gz", package)),
116156
});
117157
}
158+
118159
manifest.artifacts.insert(
119160
KnownArtifactKind::ControlPlane,
120161
vec![DeserializedArtifactData {

installinator/src/dispatch.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,9 @@ impl InstallOpts {
279279
control_plane_hash =
280280
Some(artifact.hash);
281281
}
282+
InstallinatorArtifactKind::MeasurementCorpus => {
283+
// Skip doing anything with this for the moment
284+
},
282285
}
283286
}
284287

nexus/reconfigurator/planning/src/mgs_updates/rot_bootloader.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ pub fn try_make_update_rot_bootloader(
144144
| KnownArtifactKind::Trampoline
145145
| KnownArtifactKind::ControlPlane
146146
| KnownArtifactKind::Zone
147+
| KnownArtifactKind::MeasurementCorpus
147148
| KnownArtifactKind::PscRot
148149
| KnownArtifactKind::SwitchRot
149150
| KnownArtifactKind::GimletSp

nexus/reconfigurator/planning/src/mgs_updates/sp.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ pub fn try_make_update_sp(
121121
| KnownArtifactKind::InstallinatorDocument
122122
| KnownArtifactKind::ControlPlane
123123
| KnownArtifactKind::Zone
124+
| KnownArtifactKind::MeasurementCorpus
124125
| KnownArtifactKind::PscRot
125126
| KnownArtifactKind::SwitchRot
126127
| KnownArtifactKind::GimletRotBootloader

update-common/src/artifacts/update_plan.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ impl<'a> UpdatePlanBuilder<'a> {
275275
)
276276
.await
277277
}
278-
KnownArtifactKind::Zone => {
278+
KnownArtifactKind::Zone | KnownArtifactKind::MeasurementCorpus => {
279279
// We don't currently support repos with already split-out
280280
// zones.
281281
self.add_unknown_artifact(artifact_id, artifact_hash, stream)
@@ -302,6 +302,7 @@ impl<'a> UpdatePlanBuilder<'a> {
302302
| KnownArtifactKind::InstallinatorDocument
303303
| KnownArtifactKind::ControlPlane
304304
| KnownArtifactKind::Zone
305+
| KnownArtifactKind::MeasurementCorpus
305306
| KnownArtifactKind::PscRot
306307
| KnownArtifactKind::SwitchRot
307308
| KnownArtifactKind::GimletRotBootloader
@@ -397,6 +398,7 @@ impl<'a> UpdatePlanBuilder<'a> {
397398
| KnownArtifactKind::InstallinatorDocument
398399
| KnownArtifactKind::ControlPlane
399400
| KnownArtifactKind::Zone
401+
| KnownArtifactKind::MeasurementCorpus
400402
| KnownArtifactKind::PscRot
401403
| KnownArtifactKind::SwitchRot
402404
| KnownArtifactKind::GimletSp
@@ -503,6 +505,7 @@ impl<'a> UpdatePlanBuilder<'a> {
503505
| KnownArtifactKind::InstallinatorDocument
504506
| KnownArtifactKind::ControlPlane
505507
| KnownArtifactKind::Zone
508+
| KnownArtifactKind::MeasurementCorpus
506509
| KnownArtifactKind::PscSp
507510
| KnownArtifactKind::SwitchSp
508511
| KnownArtifactKind::GimletRotBootloader

workspace-hack/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ scopeguard = { version = "1.2.0" }
117117
semver = { version = "1.0.26", features = ["serde"] }
118118
serde = { version = "1.0.219", features = ["alloc", "derive", "rc"] }
119119
serde_json = { version = "1.0.142", features = ["raw_value", "unbounded_depth"] }
120+
serde_with = { version = "3.14.0" }
120121
sha1 = { version = "0.10.6", features = ["oid"] }
121122
sha2 = { version = "0.10.9", features = ["oid"] }
122123
similar = { version = "2.7.0", features = ["bytes", "inline", "unicode"] }
@@ -254,6 +255,7 @@ scopeguard = { version = "1.2.0" }
254255
semver = { version = "1.0.26", features = ["serde"] }
255256
serde = { version = "1.0.219", features = ["alloc", "derive", "rc"] }
256257
serde_json = { version = "1.0.142", features = ["raw_value", "unbounded_depth"] }
258+
serde_with = { version = "3.14.0" }
257259
sha1 = { version = "0.10.6", features = ["oid"] }
258260
sha2 = { version = "0.10.9", features = ["oid"] }
259261
similar = { version = "2.7.0", features = ["bytes", "inline", "unicode"] }

0 commit comments

Comments
 (0)