Skip to content

Commit 4e57962

Browse files
authored
Add measurement manifest to reconfigurator-cli (#9733)
1 parent 363d7a7 commit 4e57962

7 files changed

Lines changed: 129 additions & 32 deletions

File tree

dev-tools/reconfigurator-cli/src/lib.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2085,9 +2085,15 @@ fn cmd_sled_update_install_dataset(
20852085
let mut state = sim.current_state().to_mut();
20862086
let system = state.system_mut();
20872087
let sled_id = args.sled_id.to_sled_id(system.description())?;
2088-
system
2089-
.description_mut()
2090-
.sled_set_zone_manifest(sled_id, description.to_boot_inventory())?;
2088+
system.description_mut().sled_set_zone_manifest(
2089+
sled_id,
2090+
description.to_zone_boot_inventory(),
2091+
)?;
2092+
2093+
system.description_mut().sled_set_measurement_manifest(
2094+
sled_id,
2095+
description.to_measurement_boot_inventory(),
2096+
)?;
20912097

20922098
sim.commit_and_bump(
20932099
format!(
@@ -3463,6 +3469,9 @@ fn mupdate_source_to_description(
34633469
let description = extract_tuf_repo_description(&sim.log, repo_path)?;
34643470
let mut sim_source = SimTufRepoSource::new(
34653471
description,
3472+
// We might consider having these be different for testing purposes
3473+
// but for now having them be the same is fine
3474+
manifest_source,
34663475
manifest_source,
34673476
format!("from repo at {repo_path}"),
34683477
)?;
@@ -3486,6 +3495,7 @@ fn mupdate_source_to_description(
34863495
let mut sim_source = SimTufRepoSource::new(
34873496
desc.clone(),
34883497
manifest_source,
3498+
manifest_source,
34893499
"to target release".to_owned(),
34903500
)?;
34913501
sim_source.simulate_zone_errors(&source.with_zone_error)?;

dev-tools/reconfigurator-cli/tests/output/cmds-mupdate-update-flow-stdout

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,9 @@ LEDGERED SLED CONFIG
432432
measurement manifest:
433433
path on boot disk: /fake/path/install/zones.json
434434
boot disk inventory:
435-
manifest generated by installinator (mupdate ID: 00000000-0000-0000-0000-000000000000)
436-
no artifacts in install dataset (this should only be seen in simulated systems)
435+
manifest generated by sled-agent
436+
artifacts in install dataset:
437+
- fake-corpus (expected 1048576 bytes with hash 8a0e23157bae655fceec7376926c9758efee6511c7b7ff8355bbb49545a2257f): ok
437438
no non-boot disks
438439
mupdate override:
439440
path on boot disk: /fake/path/install/mupdate_override.json

dev-tools/reconfigurator-cli/tests/output/cmds-nexus-generation-autobump-stdout

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -706,8 +706,9 @@ LEDGERED SLED CONFIG
706706
measurement manifest:
707707
path on boot disk: /fake/path/install/zones.json
708708
boot disk inventory:
709-
manifest generated by installinator (mupdate ID: 00000000-0000-0000-0000-000000000000)
710-
no artifacts in install dataset (this should only be seen in simulated systems)
709+
manifest generated by sled-agent
710+
artifacts in install dataset:
711+
- fake-corpus (expected 1048576 bytes with hash 8a0e23157bae655fceec7376926c9758efee6511c7b7ff8355bbb49545a2257f): ok
711712
no non-boot disks
712713
mupdate override:
713714
path on boot disk: /fake/path/install/mupdate_override.json
@@ -893,8 +894,9 @@ LEDGERED SLED CONFIG
893894
measurement manifest:
894895
path on boot disk: /fake/path/install/zones.json
895896
boot disk inventory:
896-
manifest generated by installinator (mupdate ID: 00000000-0000-0000-0000-000000000000)
897-
no artifacts in install dataset (this should only be seen in simulated systems)
897+
manifest generated by sled-agent
898+
artifacts in install dataset:
899+
- fake-corpus (expected 1048576 bytes with hash 8a0e23157bae655fceec7376926c9758efee6511c7b7ff8355bbb49545a2257f): ok
898900
no non-boot disks
899901
mupdate override:
900902
path on boot disk: /fake/path/install/mupdate_override.json
@@ -1080,8 +1082,9 @@ LEDGERED SLED CONFIG
10801082
measurement manifest:
10811083
path on boot disk: /fake/path/install/zones.json
10821084
boot disk inventory:
1083-
manifest generated by installinator (mupdate ID: 00000000-0000-0000-0000-000000000000)
1084-
no artifacts in install dataset (this should only be seen in simulated systems)
1085+
manifest generated by sled-agent
1086+
artifacts in install dataset:
1087+
- fake-corpus (expected 1048576 bytes with hash 8a0e23157bae655fceec7376926c9758efee6511c7b7ff8355bbb49545a2257f): ok
10851088
no non-boot disks
10861089
mupdate override:
10871090
path on boot disk: /fake/path/install/mupdate_override.json

dev-tools/reconfigurator-cli/tests/output/cmds-target-release-stdout

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -693,8 +693,9 @@ LEDGERED SLED CONFIG
693693
measurement manifest:
694694
path on boot disk: /fake/path/install/zones.json
695695
boot disk inventory:
696-
manifest generated by installinator (mupdate ID: 00000000-0000-0000-0000-000000000000)
697-
no artifacts in install dataset (this should only be seen in simulated systems)
696+
manifest generated by sled-agent
697+
artifacts in install dataset:
698+
- fake-corpus (expected 1048576 bytes with hash 8a0e23157bae655fceec7376926c9758efee6511c7b7ff8355bbb49545a2257f): ok
698699
no non-boot disks
699700
mupdate override:
700701
path on boot disk: /fake/path/install/mupdate_override.json
@@ -880,8 +881,9 @@ LEDGERED SLED CONFIG
880881
measurement manifest:
881882
path on boot disk: /fake/path/install/zones.json
882883
boot disk inventory:
883-
manifest generated by installinator (mupdate ID: 00000000-0000-0000-0000-000000000000)
884-
no artifacts in install dataset (this should only be seen in simulated systems)
884+
manifest generated by sled-agent
885+
artifacts in install dataset:
886+
- fake-corpus (expected 1048576 bytes with hash 8a0e23157bae655fceec7376926c9758efee6511c7b7ff8355bbb49545a2257f): ok
885887
no non-boot disks
886888
mupdate override:
887889
path on boot disk: /fake/path/install/mupdate_override.json
@@ -1067,8 +1069,9 @@ LEDGERED SLED CONFIG
10671069
measurement manifest:
10681070
path on boot disk: /fake/path/install/zones.json
10691071
boot disk inventory:
1070-
manifest generated by installinator (mupdate ID: 00000000-0000-0000-0000-000000000000)
1071-
no artifacts in install dataset (this should only be seen in simulated systems)
1072+
manifest generated by sled-agent
1073+
artifacts in install dataset:
1074+
- fake-corpus (expected 1048576 bytes with hash 8a0e23157bae655fceec7376926c9758efee6511c7b7ff8355bbb49545a2257f): ok
10721075
no non-boot disks
10731076
mupdate override:
10741077
path on boot disk: /fake/path/install/mupdate_override.json

dev-tools/reconfigurator-cli/tests/output/cmds-unsafe-zone-mgs-stdout

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,9 @@ LEDGERED SLED CONFIG
677677
measurement manifest:
678678
path on boot disk: /fake/path/install/zones.json
679679
boot disk inventory:
680-
manifest generated by installinator (mupdate ID: 00000000-0000-0000-0000-000000000000)
681-
no artifacts in install dataset (this should only be seen in simulated systems)
680+
manifest generated by sled-agent
681+
artifacts in install dataset:
682+
- fake-corpus (expected 1048576 bytes with hash 8a0e23157bae655fceec7376926c9758efee6511c7b7ff8355bbb49545a2257f): ok
682683
no non-boot disks
683684
mupdate override:
684685
path on boot disk: /fake/path/install/mupdate_override.json
@@ -864,8 +865,9 @@ LEDGERED SLED CONFIG
864865
measurement manifest:
865866
path on boot disk: /fake/path/install/zones.json
866867
boot disk inventory:
867-
manifest generated by installinator (mupdate ID: 00000000-0000-0000-0000-000000000000)
868-
no artifacts in install dataset (this should only be seen in simulated systems)
868+
manifest generated by sled-agent
869+
artifacts in install dataset:
870+
- fake-corpus (expected 1048576 bytes with hash 8a0e23157bae655fceec7376926c9758efee6511c7b7ff8355bbb49545a2257f): ok
869871
no non-boot disks
870872
mupdate override:
871873
path on boot disk: /fake/path/install/mupdate_override.json
@@ -1051,8 +1053,9 @@ LEDGERED SLED CONFIG
10511053
measurement manifest:
10521054
path on boot disk: /fake/path/install/zones.json
10531055
boot disk inventory:
1054-
manifest generated by installinator (mupdate ID: 00000000-0000-0000-0000-000000000000)
1055-
no artifacts in install dataset (this should only be seen in simulated systems)
1056+
manifest generated by sled-agent
1057+
artifacts in install dataset:
1058+
- fake-corpus (expected 1048576 bytes with hash 8a0e23157bae655fceec7376926c9758efee6511c7b7ff8355bbb49545a2257f): ok
10561059
no non-boot disks
10571060
mupdate override:
10581061
path on boot disk: /fake/path/install/mupdate_override.json

nexus/reconfigurator/planning/src/system.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,17 @@ impl SystemDescription {
683683
Ok(self)
684684
}
685685

686+
/// Set the measurement manifest for a sled from a provided `TufRepoDescription`.
687+
pub fn sled_set_measurement_manifest(
688+
&mut self,
689+
sled_id: SledUuid,
690+
boot_inventory: Result<ManifestBootInventory, String>,
691+
) -> anyhow::Result<&mut Self> {
692+
let sled = self.get_sled_mut(sled_id)?;
693+
sled.set_measurement_manifest(boot_inventory);
694+
Ok(self)
695+
}
696+
686697
pub fn sled_sp_active_version(
687698
&self,
688699
sled_id: SledUuid,
@@ -1757,6 +1768,16 @@ impl Sled {
17571768
.boot_inventory = boot_inventory;
17581769
}
17591770

1771+
fn set_measurement_manifest(
1772+
&mut self,
1773+
boot_inventory: Result<ManifestBootInventory, String>,
1774+
) {
1775+
self.inventory_sled_agent
1776+
.file_source_resolver
1777+
.measurement_manifest
1778+
.boot_inventory = boot_inventory;
1779+
}
1780+
17601781
/// Update the reported RoT bootloader versions
17611782
///
17621783
/// If either field is `None`, that field is _unchanged_.

nexus/reconfigurator/simulation/src/zone_images.rs

Lines changed: 65 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,24 @@ impl SimTufRepoDescription {
4343
Self { source: Err(message.clone()), message }
4444
}
4545

46-
/// Generates a simulated [`ManifestBootInventory`] or an error.
47-
pub fn to_boot_inventory(&self) -> Result<ManifestBootInventory, String> {
46+
/// Generates a simulated [`ManifestBootInventory`] for zones or an error.
47+
pub fn to_zone_boot_inventory(
48+
&self,
49+
) -> Result<ManifestBootInventory, String> {
4850
match &self.source {
49-
Ok(source) => Ok(source.to_boot_inventory()),
51+
Ok(source) => Ok(source.to_zone_boot_inventory()),
52+
Err(error) => {
53+
Err(format!("reconfigurator-sim simulated error: {error}"))
54+
}
55+
}
56+
}
57+
58+
/// Generates a simulated [`ManifestBootInventory`] for measurements or an error.
59+
pub fn to_measurement_boot_inventory(
60+
&self,
61+
) -> Result<ManifestBootInventory, String> {
62+
match &self.source {
63+
Ok(source) => Ok(source.to_measurement_boot_inventory()),
5064
Err(error) => {
5165
Err(format!("reconfigurator-sim simulated error: {error}"))
5266
}
@@ -59,7 +73,8 @@ impl SimTufRepoDescription {
5973
#[derive(Clone, Debug)]
6074
pub struct SimTufRepoSource {
6175
description: TufRepoDescription,
62-
manifest_source: OmicronInstallManifestSource,
76+
zone_manifest_source: OmicronInstallManifestSource,
77+
measurement_manifest_source: OmicronInstallManifestSource,
6378
message: String,
6479
known_artifact_id_names: BTreeSet<String>,
6580
error_artifact_id_names: BTreeSet<String>,
@@ -71,7 +86,8 @@ impl SimTufRepoSource {
7186
/// The message should be of the form "from repo at ..." or "to target release".
7287
pub fn new(
7388
description: TufRepoDescription,
74-
manifest_source: OmicronInstallManifestSource,
89+
zone_manifest_source: OmicronInstallManifestSource,
90+
measurement_manifest_source: OmicronInstallManifestSource,
7591
message: String,
7692
) -> anyhow::Result<Self> {
7793
let mut unknown = BTreeSet::new();
@@ -106,7 +122,8 @@ impl SimTufRepoSource {
106122
}
107123
Ok(Self {
108124
description,
109-
manifest_source,
125+
zone_manifest_source,
126+
measurement_manifest_source,
110127
message,
111128
known_artifact_id_names: known,
112129
error_artifact_id_names: BTreeSet::new(),
@@ -141,8 +158,47 @@ impl SimTufRepoSource {
141158
Ok(())
142159
}
143160

144-
/// Generates a simulated [`ManifestBootInventory`].
145-
pub fn to_boot_inventory(&self) -> ManifestBootInventory {
161+
/// Generates a simulated [`ManifestBootInventory`] from the measurement manifest.
162+
pub fn to_measurement_boot_inventory(&self) -> ManifestBootInventory {
163+
let artifacts = self
164+
.description
165+
.artifacts
166+
.iter()
167+
.filter_map(|artifact| {
168+
if artifact.id.kind.to_known()
169+
!= Some(KnownArtifactKind::MeasurementCorpus)
170+
{
171+
return None;
172+
}
173+
174+
let file_name = artifact.id.name.to_string();
175+
let path = Utf8Path::new("/fake/path/install").join(&file_name);
176+
let status =
177+
if self.error_artifact_id_names.contains(&artifact.id.name)
178+
{
179+
Err("reconfigurator-sim: simulated error \
180+
validating zone image"
181+
.to_owned())
182+
} else {
183+
Ok(())
184+
};
185+
Some(ZoneArtifactInventory {
186+
file_name,
187+
path,
188+
expected_size: artifact.size,
189+
expected_hash: artifact.hash,
190+
status,
191+
})
192+
})
193+
.collect();
194+
ManifestBootInventory {
195+
source: self.measurement_manifest_source,
196+
artifacts,
197+
}
198+
}
199+
200+
/// Generates a simulated [`ManifestBootInventory`] from the zone manifest.
201+
pub fn to_zone_boot_inventory(&self) -> ManifestBootInventory {
146202
let artifacts = self
147203
.description
148204
.artifacts
@@ -178,7 +234,7 @@ impl SimTufRepoSource {
178234
})
179235
})
180236
.collect();
181-
ManifestBootInventory { source: self.manifest_source, artifacts }
237+
ManifestBootInventory { source: self.zone_manifest_source, artifacts }
182238
}
183239

184240
/// Returns a message including the system version and the number of zone

0 commit comments

Comments
 (0)