Skip to content

Commit c698911

Browse files
authored
add reconfigurator-cli command for bumping Nexus generation (#9033)
1 parent 4cb26a0 commit c698911

13 files changed

+753
-16
lines changed

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

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
//! developer REPL for driving blueprint planning
66
7-
use anyhow::{Context, anyhow, bail};
7+
use anyhow::{Context, anyhow, bail, ensure};
88
use camino::{Utf8Path, Utf8PathBuf};
99
use chrono::{DateTime, Utc};
1010
use clap::{ArgAction, ValueEnum};
@@ -778,7 +778,7 @@ enum BlueprintEditCommands {
778778
generation: Generation,
779779
},
780780
/// expunge a zone
781-
ExpungeZone { zone_id: OmicronZoneUuid },
781+
ExpungeZones { zone_ids: Vec<OmicronZoneUuid> },
782782
/// mark an expunged zone ready for cleanup
783783
MarkForCleanup { zone_id: OmicronZoneUuid },
784784
/// configure an SP update
@@ -807,6 +807,11 @@ enum BlueprintEditCommands {
807807
#[command(subcommand)]
808808
command: BlueprintEditDebugCommands,
809809
},
810+
/// bumps the blueprint's Nexus generation
811+
///
812+
/// This initiates a handoff from the current generation of Nexus zones to
813+
/// the next generation of Nexus zones.
814+
BumpNexusGeneration,
810815
}
811816

812817
#[derive(Debug, Subcommand)]
@@ -2180,6 +2185,29 @@ fn cmd_blueprint_edit(
21802185
.context("failed to add CockroachDB zone")?;
21812186
format!("added CockroachDB zone to sled {}", sled_id)
21822187
}
2188+
BlueprintEditCommands::BumpNexusGeneration => {
2189+
let current_generation = builder.nexus_generation();
2190+
let current_max = blueprint
2191+
.all_nexus_zones(BlueprintZoneDisposition::is_in_service)
2192+
.fold(
2193+
current_generation,
2194+
|current_max, (_sled_id, _zone_config, nexus_config)| {
2195+
std::cmp::max(
2196+
nexus_config.nexus_generation,
2197+
current_max,
2198+
)
2199+
},
2200+
);
2201+
ensure!(
2202+
current_max > current_generation,
2203+
"cannot bump blueprint generation (currently \
2204+
{current_generation}) past highest deployed Nexus \
2205+
generation (currently {current_max})",
2206+
);
2207+
let next = current_generation.next();
2208+
builder.set_nexus_generation(next);
2209+
format!("nexus generation: {current_generation} -> {next}")
2210+
}
21832211
BlueprintEditCommands::SetRemoveMupdateOverride { sled_id, value } => {
21842212
let sled_id = sled_id.to_sled_id(system.description())?;
21852213
builder
@@ -2235,12 +2263,16 @@ fn cmd_blueprint_edit(
22352263
.context("failed to set host phase 2 source")?;
22362264
rv
22372265
}
2238-
BlueprintEditCommands::ExpungeZone { zone_id } => {
2239-
let sled_id = sled_with_zone(&builder, &zone_id)?;
2240-
builder
2241-
.sled_expunge_zone(sled_id, zone_id)
2242-
.context("failed to expunge zone")?;
2243-
format!("expunged zone {zone_id} from sled {sled_id}")
2266+
BlueprintEditCommands::ExpungeZones { zone_ids } => {
2267+
let mut rv = String::new();
2268+
for zone_id in zone_ids {
2269+
let sled_id = sled_with_zone(&builder, &zone_id)?;
2270+
builder.sled_expunge_zone(sled_id, zone_id).with_context(
2271+
|| format!("failed to expunge zone {zone_id}"),
2272+
)?;
2273+
swriteln!(rv, "expunged zone {zone_id} from sled {sled_id}");
2274+
}
2275+
rv
22442276
}
22452277
BlueprintEditCommands::MarkForCleanup { zone_id } => {
22462278
let sled_id = sled_with_zone(&builder, &zone_id)?;

dev-tools/reconfigurator-cli/tests/input/cmds-expunge-newly-added-external-dns.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
load-example --seed test_expunge_newly_added_external_dns
44

55
blueprint-show 3f00b694-1b16-4aaa-8f78-e6b3a527b434
6-
blueprint-edit 3f00b694-1b16-4aaa-8f78-e6b3a527b434 expunge-zone 8429c772-07e8-40a6-acde-2ed47d16cf84
6+
blueprint-edit 3f00b694-1b16-4aaa-8f78-e6b3a527b434 expunge-zones 8429c772-07e8-40a6-acde-2ed47d16cf84
77

88
# Diff DNS to see that the expunged zone is no longer has DNS records.
99
blueprint-diff 3f00b694-1b16-4aaa-8f78-e6b3a527b434 366b0b68-d80e-4bc1-abd3-dc69837847e0
@@ -15,5 +15,5 @@ blueprint-diff 366b0b68-d80e-4bc1-abd3-dc69837847e0 9c998c1d-1a7b-440a-ae0c-40f7
1515

1616
blueprint-show 9c998c1d-1a7b-440a-ae0c-40f781dea6e2
1717
# expunging the new zone should work, then diff again to see the new zone also have its DNS records removed.
18-
blueprint-edit 9c998c1d-1a7b-440a-ae0c-40f781dea6e2 expunge-zone 8c0a1969-15b6-4165-ba6d-a27c24151037
18+
blueprint-edit 9c998c1d-1a7b-440a-ae0c-40f781dea6e2 expunge-zones 8c0a1969-15b6-4165-ba6d-a27c24151037
1919
blueprint-diff 9c998c1d-1a7b-440a-ae0c-40f781dea6e2 2ac8c740-444d-42ff-8d66-9812a7e51288

dev-tools/reconfigurator-cli/tests/input/cmds-expunge-newly-added-internal-dns.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ load-example
22

33
blueprint-show dbcbd3d6-41ff-48ae-ac0b-1becc9b2fd21
44
# Expunge an internal DNS zone
5-
blueprint-edit dbcbd3d6-41ff-48ae-ac0b-1becc9b2fd21 expunge-zone 99e2f30b-3174-40bf-a78a-90da8abba8ca
5+
blueprint-edit dbcbd3d6-41ff-48ae-ac0b-1becc9b2fd21 expunge-zones 99e2f30b-3174-40bf-a78a-90da8abba8ca
66
# Diff against the new blueprint; the zone has been expunged so its records should be removed.
77
blueprint-diff dbcbd3d6-41ff-48ae-ac0b-1becc9b2fd21 8da82a8e-bf97-4fbd-8ddd-9f6462732cf1
88

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Load example system
2+
load-example --nsleds 3 --ndisks-per-sled 3
3+
blueprint-list
4+
blueprint-show dbcbd3d6-41ff-48ae-ac0b-1becc9b2fd21
5+
6+
# Expunge one zone.
7+
blueprint-edit dbcbd3d6-41ff-48ae-ac0b-1becc9b2fd21 expunge-zones 694bd14f-cb24-4be4-bb19-876e79cda2c8
8+
blueprint-diff 8da82a8e-bf97-4fbd-8ddd-9f6462732cf1
9+
10+
# Expunge multiple zones.
11+
blueprint-edit 8da82a8e-bf97-4fbd-8ddd-9f6462732cf1 expunge-zones 7c252b64-c5af-4ec1-989e-9a03f3b0f111 dfac80b4-a887-430a-ae87-a4e065dba787
12+
blueprint-diff 58d5e830-0884-47d8-a7cd-b2b3751adeb4
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Load example system
2+
load-example --nsleds 3 --ndisks-per-sled 3
3+
4+
# Print the initial configuration
5+
show
6+
sled-list
7+
8+
# Try to bump the Nexus generation. This should not work because you can't
9+
# bump it to a generation that has no Nexus instances deployed.
10+
blueprint-edit dbcbd3d6-41ff-48ae-ac0b-1becc9b2fd21 bump-nexus-generation
11+
12+
# Now, deploy a Nexus instance at the next generation.
13+
blueprint-edit dbcbd3d6-41ff-48ae-ac0b-1becc9b2fd21 add-nexus serial0 2
14+
blueprint-diff 8da82a8e-bf97-4fbd-8ddd-9f6462732cf1
15+
16+
# Now we can bump the Nexus generation to trigger a handoff.
17+
blueprint-edit 8da82a8e-bf97-4fbd-8ddd-9f6462732cf1 bump-nexus-generation
18+
blueprint-diff 58d5e830-0884-47d8-a7cd-b2b3751adeb4

dev-tools/reconfigurator-cli/tests/output/cmds-expunge-newly-added-external-dns-stdout

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,11 @@ empty planning report for blueprint 3f00b694-1b16-4aaa-8f78-e6b3a527b434.
339339

340340

341341

342-
> blueprint-edit 3f00b694-1b16-4aaa-8f78-e6b3a527b434 expunge-zone 8429c772-07e8-40a6-acde-2ed47d16cf84
342+
> blueprint-edit 3f00b694-1b16-4aaa-8f78-e6b3a527b434 expunge-zones 8429c772-07e8-40a6-acde-2ed47d16cf84
343343
blueprint 366b0b68-d80e-4bc1-abd3-dc69837847e0 created from blueprint 3f00b694-1b16-4aaa-8f78-e6b3a527b434: expunged zone 8429c772-07e8-40a6-acde-2ed47d16cf84 from sled 711ac7f8-d19e-4572-bdb9-e9b50f6e362a
344344

345345

346+
346347
> # Diff DNS to see that the expunged zone is no longer has DNS records.
347348
> blueprint-diff 3f00b694-1b16-4aaa-8f78-e6b3a527b434 366b0b68-d80e-4bc1-abd3-dc69837847e0
348349
from: blueprint 3f00b694-1b16-4aaa-8f78-e6b3a527b434
@@ -1346,9 +1347,10 @@ planning report for blueprint 9c998c1d-1a7b-440a-ae0c-40f781dea6e2:
13461347

13471348

13481349
> # expunging the new zone should work, then diff again to see the new zone also have its DNS records removed.
1349-
> blueprint-edit 9c998c1d-1a7b-440a-ae0c-40f781dea6e2 expunge-zone 8c0a1969-15b6-4165-ba6d-a27c24151037
1350+
> blueprint-edit 9c998c1d-1a7b-440a-ae0c-40f781dea6e2 expunge-zones 8c0a1969-15b6-4165-ba6d-a27c24151037
13501351
blueprint 2ac8c740-444d-42ff-8d66-9812a7e51288 created from blueprint 9c998c1d-1a7b-440a-ae0c-40f781dea6e2: expunged zone 8c0a1969-15b6-4165-ba6d-a27c24151037 from sled 9dc50690-f9bf-4520-bf80-051d0f465c2c
13511352

1353+
13521354
> blueprint-diff 9c998c1d-1a7b-440a-ae0c-40f781dea6e2 2ac8c740-444d-42ff-8d66-9812a7e51288
13531355
from: blueprint 9c998c1d-1a7b-440a-ae0c-40f781dea6e2
13541356
to: blueprint 2ac8c740-444d-42ff-8d66-9812a7e51288

dev-tools/reconfigurator-cli/tests/output/cmds-expunge-newly-added-internal-dns-stdout

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,10 @@ empty planning report for blueprint dbcbd3d6-41ff-48ae-ac0b-1becc9b2fd21.
338338

339339

340340
> # Expunge an internal DNS zone
341-
> blueprint-edit dbcbd3d6-41ff-48ae-ac0b-1becc9b2fd21 expunge-zone 99e2f30b-3174-40bf-a78a-90da8abba8ca
341+
> blueprint-edit dbcbd3d6-41ff-48ae-ac0b-1becc9b2fd21 expunge-zones 99e2f30b-3174-40bf-a78a-90da8abba8ca
342342
blueprint 8da82a8e-bf97-4fbd-8ddd-9f6462732cf1 created from blueprint dbcbd3d6-41ff-48ae-ac0b-1becc9b2fd21: expunged zone 99e2f30b-3174-40bf-a78a-90da8abba8ca from sled 2b8f0cb3-0295-4b3c-bc58-4fe88b57112c
343343

344+
344345
> # Diff against the new blueprint; the zone has been expunged so its records should be removed.
345346
> blueprint-diff dbcbd3d6-41ff-48ae-ac0b-1becc9b2fd21 8da82a8e-bf97-4fbd-8ddd-9f6462732cf1
346347
from: blueprint dbcbd3d6-41ff-48ae-ac0b-1becc9b2fd21

dev-tools/reconfigurator-cli/tests/output/cmds-expunge-zones-stderr

Whitespace-only changes.

0 commit comments

Comments
 (0)