Skip to content

Commit b854ba2

Browse files
authored
Add desired host phase 2 contents to blueprint (#8570)
This is a followup to the stack of PRs that added desired host phase 2 contents to `OmicronSledConfig` (#8538 and its followups). We now have a `BlueprintHostPhase2DesiredSlots` inside each `BlueprintSledConfig` that specifies the desired contents (artifact by hash-and-version or "just the current contents", analogous to the install dataset for zones) for each of the two phase 2 slots.
1 parent c3ec70c commit b854ba2

File tree

51 files changed

+3264
-136
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+3264
-136
lines changed

dev-tools/omdb/tests/successes.out

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,6 +1461,14 @@ parent: <none>
14611461

14621462
sled: ..........<REDACTED_UUID>........... (active, config generation 2)
14631463

1464+
host phase 2 contents:
1465+
------------------------
1466+
slot boot image source
1467+
------------------------
1468+
A current contents
1469+
B current contents
1470+
1471+
14641472
physical disks:
14651473
-----------------------------------------------------------------
14661474
vendor model serial disposition
@@ -1492,6 +1500,14 @@ parent: <none>
14921500

14931501
sled: ..........<REDACTED_UUID>........... (active, config generation 2)
14941502

1503+
host phase 2 contents:
1504+
------------------------
1505+
slot boot image source
1506+
------------------------
1507+
A current contents
1508+
B current contents
1509+
1510+
14951511
physical disks:
14961512
----------------------------------------------------------------
14971513
vendor model serial disposition
@@ -1565,6 +1581,14 @@ parent: <none>
15651581

15661582
sled: ..........<REDACTED_UUID>........... (active, config generation 2)
15671583

1584+
host phase 2 contents:
1585+
------------------------
1586+
slot boot image source
1587+
------------------------
1588+
A current contents
1589+
B current contents
1590+
1591+
15681592
physical disks:
15691593
-----------------------------------------------------------------
15701594
vendor model serial disposition
@@ -1596,6 +1620,14 @@ parent: <none>
15961620

15971621
sled: ..........<REDACTED_UUID>........... (active, config generation 2)
15981622

1623+
host phase 2 contents:
1624+
------------------------
1625+
slot boot image source
1626+
------------------------
1627+
A current contents
1628+
B current contents
1629+
1630+
15991631
physical disks:
16001632
----------------------------------------------------------------
16011633
vendor model serial disposition

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

Lines changed: 70 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,25 @@ use nexus_reconfigurator_simulation::{BlueprintId, CollectionId, SimState};
2626
use nexus_reconfigurator_simulation::{SimStateBuilder, SimTufRepoSource};
2727
use nexus_reconfigurator_simulation::{SimTufRepoDescription, Simulator};
2828
use nexus_sled_agent_shared::inventory::ZoneKind;
29+
use nexus_types::deployment::BlueprintHostPhase2DesiredContents;
2930
use nexus_types::deployment::PlanningInput;
3031
use nexus_types::deployment::SledFilter;
3132
use nexus_types::deployment::execution;
3233
use nexus_types::deployment::execution::blueprint_external_dns_config;
3334
use nexus_types::deployment::execution::blueprint_internal_dns_config;
3435
use nexus_types::deployment::{Blueprint, UnstableReconfiguratorState};
36+
use nexus_types::deployment::{BlueprintArtifactVersion, PendingMgsUpdate};
3537
use nexus_types::deployment::{BlueprintZoneDisposition, ExpectedVersion};
3638
use nexus_types::deployment::{
3739
BlueprintZoneImageSource, PendingMgsUpdateDetails,
3840
};
39-
use nexus_types::deployment::{BlueprintZoneImageVersion, PendingMgsUpdate};
4041
use nexus_types::deployment::{OmicronZoneNic, TargetReleaseDescription};
4142
use nexus_types::external_api::views::SledPolicy;
4243
use nexus_types::external_api::views::SledProvisionPolicy;
4344
use omicron_common::address::REPO_DEPOT_PORT;
4445
use omicron_common::api::external::Name;
4546
use omicron_common::api::external::{Generation, TufRepoDescription};
47+
use omicron_common::disk::M2Slot;
4648
use omicron_common::policy::NEXUS_REDUNDANCY;
4749
use omicron_common::update::OmicronZoneManifestSource;
4850
use omicron_repl_utils::run_repl_from_file;
@@ -573,6 +575,16 @@ enum BlueprintEditCommands {
573575
#[command(subcommand)]
574576
image_source: ImageSourceArgs,
575577
},
578+
/// set the desired host phase 2 image for an internal disk slot
579+
SetHostPhase2 {
580+
/// sled to set the field on
581+
sled_id: SledOpt,
582+
/// internal disk slot
583+
#[clap(value_parser = parse_m2_slot)]
584+
slot: M2Slot,
585+
#[command(subcommand)]
586+
phase_2_source: HostPhase2SourceArgs,
587+
},
576588
/// set the remove_mupdate_override field for a sled
577589
SetRemoveMupdateOverride {
578590
/// sled to set the field on
@@ -841,8 +853,8 @@ enum ImageSourceArgs {
841853
InstallDataset,
842854
/// the zone image comes from a specific TUF repo artifact
843855
Artifact {
844-
#[clap(value_parser = parse_blueprint_zone_image_version)]
845-
version: BlueprintZoneImageVersion,
856+
#[clap(value_parser = parse_blueprint_artifact_version)]
857+
version: BlueprintArtifactVersion,
846858
hash: ArtifactHash,
847859
},
848860
}
@@ -881,10 +893,10 @@ fn image_source_unwrap_or(
881893
Ok(BlueprintZoneImageSource::InstallDataset) | Err(_) => (),
882894
Ok(BlueprintZoneImageSource::Artifact { version, hash }) => {
883895
let version = match version {
884-
BlueprintZoneImageVersion::Available { version } => {
896+
BlueprintArtifactVersion::Available { version } => {
885897
version.to_string()
886898
}
887-
BlueprintZoneImageVersion::Unknown => {
899+
BlueprintArtifactVersion::Unknown => {
888900
"unknown".to_string()
889901
}
890902
};
@@ -914,19 +926,50 @@ impl From<ImageSourceArgs> for BlueprintZoneImageSource {
914926
}
915927
}
916928

917-
fn parse_blueprint_zone_image_version(
929+
#[derive(Debug, Subcommand)]
930+
enum HostPhase2SourceArgs {
931+
/// keep the current phase 2 contents
932+
CurrentContents,
933+
/// the host phase 2 comes from a specific TUF repo artifact
934+
Artifact {
935+
#[clap(value_parser = parse_blueprint_artifact_version)]
936+
version: BlueprintArtifactVersion,
937+
hash: ArtifactHash,
938+
},
939+
}
940+
941+
impl From<HostPhase2SourceArgs> for BlueprintHostPhase2DesiredContents {
942+
fn from(value: HostPhase2SourceArgs) -> Self {
943+
match value {
944+
HostPhase2SourceArgs::CurrentContents => Self::CurrentContents,
945+
HostPhase2SourceArgs::Artifact { version, hash } => {
946+
Self::Artifact { version, hash }
947+
}
948+
}
949+
}
950+
}
951+
952+
fn parse_blueprint_artifact_version(
918953
version: &str,
919-
) -> Result<BlueprintZoneImageVersion, ArtifactVersionError> {
954+
) -> Result<BlueprintArtifactVersion, ArtifactVersionError> {
920955
// Treat the literal string "unknown" as an unknown version.
921956
if version == "unknown" {
922-
return Ok(BlueprintZoneImageVersion::Unknown);
957+
return Ok(BlueprintArtifactVersion::Unknown);
923958
}
924959

925-
Ok(BlueprintZoneImageVersion::Available {
960+
Ok(BlueprintArtifactVersion::Available {
926961
version: version.parse::<ArtifactVersion>()?,
927962
})
928963
}
929964

965+
fn parse_m2_slot(slot: &str) -> anyhow::Result<M2Slot> {
966+
match slot {
967+
"A" | "a" | "0" => Ok(M2Slot::A),
968+
"B" | "b" | "1" => Ok(M2Slot::B),
969+
_ => bail!("invalid slot `{slot}` (expected `A` or `B`)"),
970+
}
971+
}
972+
930973
#[derive(Debug, Args)]
931974
struct BlueprintArgs {
932975
/// id of the blueprint, "latest", or "target"
@@ -1637,6 +1680,24 @@ fn cmd_blueprint_edit(
16371680
.context("failed to set image source")?;
16381681
rv
16391682
}
1683+
BlueprintEditCommands::SetHostPhase2 {
1684+
sled_id,
1685+
slot,
1686+
phase_2_source,
1687+
} => {
1688+
let sled_id = sled_id.to_sled_id(system.description())?;
1689+
let source =
1690+
BlueprintHostPhase2DesiredContents::from(phase_2_source);
1691+
let rv = format!(
1692+
"set sled {sled_id} host phase 2 slot {slot:?} source to \
1693+
{source}\n\
1694+
warn: no validation is done on the requested source"
1695+
);
1696+
builder
1697+
.sled_set_host_phase_2_slot(sled_id, slot, source)
1698+
.context("failed to set host phase 2 source")?;
1699+
rv
1700+
}
16401701
BlueprintEditCommands::ExpungeZone { zone_id } => {
16411702
let sled_id = sled_with_zone(&builder, &zone_id)?;
16421703
builder
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Load example system
2+
3+
load-example --nsleds 1
4+
5+
# Set slot A
6+
blueprint-edit latest set-host-phase2 serial0 A artifact 1.0.0 3a9607047b03ccaab6d222249d890e93ca51b94ad631c7ca38be74cba60802ff
7+
blueprint-diff latest
8+
9+
# Set slot B
10+
blueprint-edit latest set-host-phase2 serial0 B artifact 2.0.0 044d45ad681b44e89c10e056cabdedf19fd8b1e54bc95e6622bcdd23f16bc8f2
11+
blueprint-diff latest
12+
13+
blueprint-show latest
14+
15+
# Restore A to "current contents"
16+
blueprint-edit latest set-host-phase2 serial0 A current-contents
17+
blueprint-diff latest
18+
19+
# Restore B to "current contents"
20+
blueprint-edit latest set-host-phase2 serial0 B current-contents
21+
blueprint-diff latest
22+
23+
blueprint-show latest

dev-tools/reconfigurator-cli/tests/output/cmds-add-sled-no-disks-stdout

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ parent: dbcbd3d6-41ff-48ae-ac0b-1becc9b2fd21
5959

6060
sled: 00320471-945d-413c-85e7-03e091a70b3c (active, config generation 1)
6161

62+
host phase 2 contents:
63+
------------------------
64+
slot boot image source
65+
------------------------
66+
A current contents
67+
B current contents
68+
69+
6270
physical disks:
6371
-------------------------------------
6472
vendor model serial disposition
@@ -80,6 +88,14 @@ parent: dbcbd3d6-41ff-48ae-ac0b-1becc9b2fd21
8088

8189
sled: 2b8f0cb3-0295-4b3c-bc58-4fe88b57112c (active, config generation 2)
8290

91+
host phase 2 contents:
92+
------------------------
93+
slot boot image source
94+
------------------------
95+
A current contents
96+
B current contents
97+
98+
8399
physical disks:
84100
------------------------------------------------------------------------------------
85101
vendor model serial disposition
@@ -134,6 +150,14 @@ parent: dbcbd3d6-41ff-48ae-ac0b-1becc9b2fd21
134150

135151
sled: 98e6b7c2-2efa-41ca-b20a-0a4d61102fe6 (active, config generation 2)
136152

153+
host phase 2 contents:
154+
------------------------
155+
slot boot image source
156+
------------------------
157+
A current contents
158+
B current contents
159+
160+
137161
physical disks:
138162
------------------------------------------------------------------------------------
139163
vendor model serial disposition
@@ -185,6 +209,14 @@ parent: dbcbd3d6-41ff-48ae-ac0b-1becc9b2fd21
185209

186210
sled: d81c6a84-79b8-4958-ae41-ea46c9b19763 (active, config generation 2)
187211

212+
host phase 2 contents:
213+
------------------------
214+
slot boot image source
215+
------------------------
216+
A current contents
217+
B current contents
218+
219+
188220
physical disks:
189221
------------------------------------------------------------------------------------
190222
vendor model serial disposition

0 commit comments

Comments
 (0)