Skip to content

Support measurement_corpus #7906

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -684,10 +684,10 @@ toml_edit = "0.22.24"
tough = { version = "0.20.0", features = [ "http" ] }
transceiver-controller = { git = "https://github.com/oxidecomputer/transceiver-control", features = [ "api-traits" ] }
trybuild = "1.0.103"
tufaceous = { git = "https://github.com/oxidecomputer/tufaceous", branch = "main" }
tufaceous-artifact = { git = "https://github.com/oxidecomputer/tufaceous", branch = "main", features = ["proptest", "schemars"] }
tufaceous-brand-metadata = { git = "https://github.com/oxidecomputer/tufaceous", branch = "main" }
tufaceous-lib = { git = "https://github.com/oxidecomputer/tufaceous", branch = "main" }
tufaceous = { git = "https://github.com/oxidecomputer/tufaceous", branch = "measurement_corpus" }
tufaceous-artifact = { git = "https://github.com/oxidecomputer/tufaceous", branch = "measurement_corpus", features = ["proptest", "schemars"] }
tufaceous-brand-metadata = { git = "https://github.com/oxidecomputer/tufaceous", branch = "measurement_corpus" }
tufaceous-lib = { git = "https://github.com/oxidecomputer/tufaceous", branch = "measurement_corpus" }
tui-tree-widget = "0.23.0"
typed-rng = { path = "typed-rng" }
typify = "0.3.0"
Expand Down
13 changes: 12 additions & 1 deletion dev-tools/releng/src/tuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,23 @@ pub(crate) async fn build_tuf_repo(
.join(format!("{}.tar.gz", package)),
});
}

// XXX fixme
let measurement_corpus = vec![
DeserailzedControlPlanZoneSource::File {
file_name: "test_manifest.cbor",
path: format!("/home/labbott/omicron/Cargo.toml"),
}
];
manifest.artifacts.insert(
KnownArtifactKind::ControlPlane,
vec![DeserializedArtifactData {
name: "control-plane".to_string(),
version: artifact_version.clone(),
source: DeserializedArtifactSource::CompositeControlPlane { zones },
source: DeserializedArtifactSource::CompositeControlPlane {
zones,
measurement_corpus,
},
}],
);

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 @@ -294,6 +294,9 @@ pub enum ControlPlaneZonesStepId {
/// Writing a zone.
Zone { name: String },

/// Writing a measurement corpus
MeasurementCorpus { name: String },

/// Syncing writes to disk.
Fsync,

Expand Down
29 changes: 29 additions & 0 deletions installinator/src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,34 @@ impl ControlPlaneZoneWriteContext<'_> {
.register();
}

for (name, data) in &self.zones.measurement_corpus {
let out_path = self.output_directory.join(name);
transport = engine
.new_step(
WriteComponent::ControlPlane,
ControlPlaneZonesStepId::MeasurementCorpus { name: name.clone() },
format!("Writing measurement corpus {name}"),
async move |cx| {
let transport = transport.into_value(cx.token()).await;
write_artifact_impl(
WriteComponent::ControlPlane,
slot,
data.clone().into(),
&out_path,
transport,
&cx,
)
.await?;

StepSuccess::new(transport).into()
},
)
.register();
}



// XXX here is where we can write the corpus
// `fsync()` the directory to ensure the directory entries for all the
// files we just created are written to disk.
let output_directory = self.output_directory.to_path_buf();
Expand Down Expand Up @@ -1106,6 +1134,7 @@ mod tests {
destination_control_plane.file_name().unwrap().to_string(),
artifact_control_plane.iter().flatten().copied().collect(),
)],
measurement_corpus: vec![],
};

let mut writer = ArtifactWriter::new(
Expand Down
28 changes: 19 additions & 9 deletions update-common/src/artifacts/update_plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ use tokio::runtime::Handle;
use tufaceous_artifact::ArtifactKind;
use tufaceous_artifact::ArtifactVersion;
use tufaceous_artifact::KnownArtifactKind;
use tufaceous_lib::ControlPlaneEntry;
use tufaceous_lib::ControlPlaneZoneImages;
use tufaceous_lib::HostPhaseImages;
use tufaceous_lib::RotArchives;
Expand Down Expand Up @@ -256,9 +257,9 @@ impl<'a> UpdatePlanBuilder<'a> {
)
.await
}
KnownArtifactKind::Zone => {
KnownArtifactKind::Zone | KnownArtifactKind::MeasurementCorpus => {
// We don't currently support repos with already split-out
// zones.
// zones and manifest.
self.add_unknown_artifact(artifact_id, artifact_hash, stream)
.await
}
Expand Down Expand Up @@ -286,7 +287,8 @@ impl<'a> UpdatePlanBuilder<'a> {
| KnownArtifactKind::SwitchRot
| KnownArtifactKind::GimletRotBootloader
| KnownArtifactKind::PscRotBootloader
| KnownArtifactKind::SwitchRotBootloader => unreachable!(),
| KnownArtifactKind::SwitchRotBootloader
| KnownArtifactKind::MeasurementCorpus => unreachable!(),
};

let mut stream = std::pin::pin!(stream);
Expand Down Expand Up @@ -379,7 +381,8 @@ impl<'a> UpdatePlanBuilder<'a> {
| KnownArtifactKind::SwitchRot
| KnownArtifactKind::GimletSp
| KnownArtifactKind::PscSp
| KnownArtifactKind::SwitchSp => unreachable!(),
| KnownArtifactKind::SwitchSp
| KnownArtifactKind::MeasurementCorpus => unreachable!(),
};

let mut stream = std::pin::pin!(stream);
Expand Down Expand Up @@ -474,7 +477,8 @@ impl<'a> UpdatePlanBuilder<'a> {
| KnownArtifactKind::SwitchSp
| KnownArtifactKind::GimletRotBootloader
| KnownArtifactKind::SwitchRotBootloader
| KnownArtifactKind::PscRotBootloader => unreachable!(),
| KnownArtifactKind::PscRotBootloader
| KnownArtifactKind::MeasurementCorpus => unreachable!(),
};

let (rot_a_data, rot_b_data) = Self::extract_nested_artifact_pair(
Expand Down Expand Up @@ -913,12 +917,18 @@ impl<'a> UpdatePlanBuilder<'a> {
&mut self,
reader: impl io::Read,
) -> Result<(), RepositoryError> {
ControlPlaneZoneImages::extract_into(reader, |_, reader| {
ControlPlaneZoneImages::extract_into(reader, |_, kind, reader| {
let known_kind = match kind {
ControlPlaneEntry::Zone => KnownArtifactKind::Zone,
ControlPlaneEntry::MeasurementCorpus => {
KnownArtifactKind::MeasurementCorpus
}
};
let mut out = self.extracted_artifacts.new_tempfile()?;
io::copy(reader, &mut out)?;
let data = self
.extracted_artifacts
.store_tempfile(KnownArtifactKind::Zone.into(), out)?;
.store_tempfile(known_kind.into(), out)?;

// Read the zone name and version from the `oxide.json` at the root
// of the zone.
Expand All @@ -934,12 +944,12 @@ impl<'a> UpdatePlanBuilder<'a> {
let artifact_id = ArtifactId {
name: info.pkg.clone(),
version: ArtifactVersion::new(info.version.to_string())?,
kind: KnownArtifactKind::Zone.into(),
kind: known_kind.into(),
};
self.record_extracted_artifact(
artifact_id,
data,
KnownArtifactKind::Zone.into(),
known_kind.into(),
self.log,
)?;
Ok(())
Expand Down
Loading