Skip to content

Commit f0144d8

Browse files
authored
[4/n] [reconfigurator-planning] add a way to set the target release at system creation time (#8939)
As part of the work in #8726, updates will only happen if all zones are at known versions before the update starts. In tests, the easiest way to achieve this is to start off the `ExampleSystem` with a target release at creation time. This PR: * adds support for that * adds a simple `0.0.1` fake manifest that tests can use * converts one of the update-related tests over to starting off with a target release, as an example. (More tests will be converted over in subsequent commits.) In order to do this, the `ExampleSystemBuilder` now needs to be aware of how to extract TUF repos. Reconfigurator-cli already had code to create and extract TUF repos, which I've moved into nexus-reconfigurator-planning. This is going to run into issues with Cosmo boards since they'll have multiple host phase 1 artifacts -- added TODOs to flag that.
1 parent 45c032b commit f0144d8

File tree

6 files changed

+446
-79
lines changed

6 files changed

+446
-79
lines changed

Cargo.lock

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

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

Lines changed: 11 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//! developer REPL for driving blueprint planning
66
77
use anyhow::{Context, anyhow, bail, ensure};
8-
use camino::{Utf8Path, Utf8PathBuf};
8+
use camino::Utf8PathBuf;
99
use chrono::{DateTime, Utc};
1010
use clap::{ArgAction, ValueEnum};
1111
use clap::{Args, Parser, Subcommand};
@@ -20,7 +20,9 @@ use nexus_inventory::CollectionBuilder;
2020
use nexus_reconfigurator_blippy::Blippy;
2121
use nexus_reconfigurator_blippy::BlippyReportSortKey;
2222
use nexus_reconfigurator_planning::blueprint_builder::BlueprintBuilder;
23-
use nexus_reconfigurator_planning::example::ExampleSystemBuilder;
23+
use nexus_reconfigurator_planning::example::{
24+
ExampleSystemBuilder, extract_tuf_repo_description, tuf_assemble,
25+
};
2426
use nexus_reconfigurator_planning::planner::Planner;
2527
use nexus_reconfigurator_planning::system::{
2628
RotStateOverrides, SledBuilder, SledInventoryVisibility, SystemDescription,
@@ -48,8 +50,8 @@ use nexus_types::external_api::views::SledPolicy;
4850
use nexus_types::external_api::views::SledProvisionPolicy;
4951
use nexus_types::inventory::CollectionDisplayCliFilter;
5052
use omicron_common::address::REPO_DEPOT_PORT;
53+
use omicron_common::api::external::Generation;
5154
use omicron_common::api::external::Name;
52-
use omicron_common::api::external::{Generation, TufRepoDescription};
5355
use omicron_common::disk::M2Slot;
5456
use omicron_common::policy::NEXUS_REDUNDANCY;
5557
use omicron_common::update::OmicronZoneManifestSource;
@@ -75,20 +77,9 @@ use tufaceous_artifact::ArtifactHash;
7577
use tufaceous_artifact::ArtifactVersion;
7678
use tufaceous_artifact::ArtifactVersionError;
7779
use tufaceous_lib::assemble::ArtifactManifest;
78-
use update_common::artifacts::{
79-
ArtifactsWithPlan, ControlPlaneZonesMode, VerificationMode,
80-
};
8180

8281
mod log_capture;
8382

84-
/// The default key for TUF repository generation.
85-
///
86-
/// This was randomly generated through a tufaceous invocation.
87-
pub static DEFAULT_TUFACEOUS_KEY: &str = "ed25519:\
88-
MFECAQEwBQYDK2VwBCIEIJ9CnAhwk8PPt1x8icu\
89-
z9c12PdfCRHJpoUkuqJmIZ8GbgSEAbNGMpsHK5_w32\
90-
qwYdZH_BeVssmKzQlFsnPuaiHx2hy0=";
91-
9283
/// REPL state
9384
#[derive(Debug)]
9485
struct ReconfiguratorSim {
@@ -2840,32 +2831,6 @@ fn mupdate_source_to_description(
28402831
}
28412832
}
28422833

2843-
fn extract_tuf_repo_description(
2844-
log: &slog::Logger,
2845-
filename: &Utf8Path,
2846-
) -> anyhow::Result<TufRepoDescription> {
2847-
let file = std::fs::File::open(filename)
2848-
.with_context(|| format!("open {:?}", filename))?;
2849-
let buf = std::io::BufReader::new(file);
2850-
let rt =
2851-
tokio::runtime::Runtime::new().context("creating tokio runtime")?;
2852-
let repo_hash = ArtifactHash([0; 32]);
2853-
let artifacts_with_plan = rt.block_on(async {
2854-
ArtifactsWithPlan::from_zip(
2855-
buf,
2856-
None,
2857-
repo_hash,
2858-
ControlPlaneZonesMode::Split,
2859-
VerificationMode::BlindlyTrustAnything,
2860-
log,
2861-
)
2862-
.await
2863-
.with_context(|| format!("unpacking {:?}", filename))
2864-
})?;
2865-
let description = artifacts_with_plan.description().clone();
2866-
Ok(description)
2867-
}
2868-
28692834
fn cmd_tuf_assemble(
28702835
sim: &ReconfiguratorSim,
28712836
args: TufAssembleArgs,
@@ -2896,30 +2861,12 @@ fn cmd_tuf_assemble(
28962861
Utf8PathBuf::from(format!("repo-{}.zip", manifest.system_version))
28972862
};
28982863

2899-
if output_path.exists() {
2900-
bail!("output path `{output_path}` already exists");
2901-
}
2902-
2903-
// Just use a fixed key for now.
2904-
//
2905-
// In the future we may want to test changing the TUF key.
2906-
let mut tufaceous_args = vec![
2907-
"tufaceous",
2908-
"--key",
2909-
DEFAULT_TUFACEOUS_KEY,
2910-
"assemble",
2911-
manifest_path.as_str(),
2912-
output_path.as_str(),
2913-
];
2914-
if args.allow_non_semver {
2915-
tufaceous_args.push("--allow-non-semver");
2916-
}
2917-
let args = tufaceous::Args::try_parse_from(tufaceous_args)
2918-
.expect("args are valid so this shouldn't fail");
2919-
let rt =
2920-
tokio::runtime::Runtime::new().context("creating tokio runtime")?;
2921-
rt.block_on(async move { args.exec(&sim.log).await })
2922-
.context("error executing tufaceous assemble")?;
2864+
tuf_assemble(
2865+
&sim.log,
2866+
&manifest_path,
2867+
&output_path,
2868+
args.allow_non_semver,
2869+
)?;
29232870

29242871
let rv = format!(
29252872
"created {} for system version {}",

nexus/reconfigurator/planning/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ workspace = true
88

99
[dependencies]
1010
anyhow.workspace = true
11+
camino.workspace = true
12+
camino-tempfile.workspace = true
13+
clap.workspace = true
1114
clickhouse-admin-types.workspace = true
1215
cockroach-admin-types.workspace = true
1316
chrono.workspace = true
@@ -41,8 +44,12 @@ static_assertions.workspace = true
4144
strum.workspace = true
4245
swrite.workspace = true
4346
thiserror.workspace = true
47+
tokio.workspace = true
48+
tufaceous.workspace = true
4449
tufaceous-artifact.workspace = true
50+
tufaceous-lib.workspace = true
4551
typed-rng.workspace = true
52+
update-common.workspace = true
4653
uuid.workspace = true
4754

4855
omicron-workspace-hack.workspace = true

0 commit comments

Comments
 (0)