Skip to content

Commit a876669

Browse files
authored
reconfigurator-cli: ability to expunge multiple zones at once (#9035)
1 parent f3de50c commit a876669

10 files changed

+522
-15
lines changed

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ enum BlueprintEditCommands {
755755
generation: Generation,
756756
},
757757
/// expunge a zone
758-
ExpungeZone { zone_id: OmicronZoneUuid },
758+
ExpungeZones { zone_ids: Vec<OmicronZoneUuid> },
759759
/// mark an expunged zone ready for cleanup
760760
MarkForCleanup { zone_id: OmicronZoneUuid },
761761
/// configure an SP update
@@ -2244,12 +2244,16 @@ fn cmd_blueprint_edit(
22442244
.context("failed to set host phase 2 source")?;
22452245
rv
22462246
}
2247-
BlueprintEditCommands::ExpungeZone { zone_id } => {
2248-
let sled_id = sled_with_zone(&builder, &zone_id)?;
2249-
builder
2250-
.sled_expunge_zone(sled_id, zone_id)
2251-
.context("failed to expunge zone")?;
2252-
format!("expunged zone {zone_id} from sled {sled_id}")
2247+
BlueprintEditCommands::ExpungeZones { zone_ids } => {
2248+
let mut rv = String::new();
2249+
for zone_id in zone_ids {
2250+
let sled_id = sled_with_zone(&builder, &zone_id)?;
2251+
builder.sled_expunge_zone(sled_id, zone_id).with_context(
2252+
|| format!("failed to expunge zone {zone_id}"),
2253+
)?;
2254+
swriteln!(rv, "expunged zone {zone_id} from sled {sled_id}");
2255+
}
2256+
rv
22532257
}
22542258
BlueprintEditCommands::MarkForCleanup { zone_id } => {
22552259
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

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)