Skip to content

Commit 08c316d

Browse files
committed
Plan zone updates from TUF repo
1 parent 53f3eab commit 08c316d

File tree

4 files changed

+632
-15
lines changed

4 files changed

+632
-15
lines changed

dev-tools/reconfigurator-cli/tests/output/cmd-expunge-newly-added-stdout

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,7 @@ INFO sufficient InternalDns zones exist in plan, desired_count: 3, current_count
628628
INFO added zone to sled, sled_id: a88790de-5962-4871-8686-61c1fd5b7094, kind: ExternalDns
629629
INFO sufficient Nexus zones exist in plan, desired_count: 3, current_count: 3
630630
INFO sufficient Oximeter zones exist in plan, desired_count: 0, current_count: 0
631+
INFO all zones up-to-date
631632
INFO will ensure cockroachdb setting, setting: cluster.preserve_downgrade_option, value: DoNotModify
632633
generated blueprint 9c998c1d-1a7b-440a-ae0c-40f781dea6e2 based on parent blueprint 366b0b68-d80e-4bc1-abd3-dc69837847e0
633634

nexus-sled-agent-shared/src/inventory.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,25 @@ impl ZoneKind {
617617
ZoneKind::Oximeter => "oximeter",
618618
}
619619
}
620+
621+
/// Return a string used as an artifact name for control-plane zones.
622+
/// This is **not guaranteed** to be stable.
623+
pub fn artifact_name(self) -> &'static str {
624+
match self {
625+
ZoneKind::BoundaryNtp => "ntp",
626+
ZoneKind::Clickhouse => "clickhouse",
627+
ZoneKind::ClickhouseKeeper => "clickhouse_keeper",
628+
ZoneKind::ClickhouseServer => "clickhouse",
629+
ZoneKind::CockroachDb => "cockroachdb",
630+
ZoneKind::Crucible => "crucible-zone",
631+
ZoneKind::CruciblePantry => "crucible-pantry-zone",
632+
ZoneKind::ExternalDns => "external-dns",
633+
ZoneKind::InternalDns => "internal-dns",
634+
ZoneKind::InternalNtp => "ntp",
635+
ZoneKind::Nexus => "nexus",
636+
ZoneKind::Oximeter => "oximeter",
637+
}
638+
}
620639
}
621640

622641
/// Where Sled Agent should get the image for a zone.

nexus/reconfigurator/planning/src/blueprint_builder/builder.rs

Lines changed: 54 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ use nexus_types::deployment::BlueprintSledConfig;
3333
use nexus_types::deployment::BlueprintZoneConfig;
3434
use nexus_types::deployment::BlueprintZoneDisposition;
3535
use nexus_types::deployment::BlueprintZoneImageSource;
36+
use nexus_types::deployment::BlueprintZoneImageVersion;
3637
use nexus_types::deployment::BlueprintZoneType;
3738
use nexus_types::deployment::ClickhouseClusterConfig;
3839
use nexus_types::deployment::CockroachDbPreserveDowngrade;
@@ -82,6 +83,7 @@ use std::net::Ipv6Addr;
8283
use std::net::SocketAddr;
8384
use std::net::SocketAddrV6;
8485
use thiserror::Error;
86+
use tufaceous_artifact::KnownArtifactKind;
8587

8688
use super::ClickhouseZonesThatShouldBeRunning;
8789
use super::clickhouse::ClickhouseAllocator;
@@ -1159,13 +1161,14 @@ impl<'a> BlueprintBuilder<'a> {
11591161
gz_address: dns_subnet.gz_address(),
11601162
gz_address_index,
11611163
});
1164+
let image_source = self.zone_image_source(zone_type.kind());
11621165

11631166
let zone = BlueprintZoneConfig {
11641167
disposition: BlueprintZoneDisposition::InService,
11651168
id: self.rng.sled_rng(sled_id).next_zone(),
11661169
filesystem_pool: zpool,
11671170
zone_type,
1168-
image_source: BlueprintZoneImageSource::InstallDataset,
1171+
image_source,
11691172
};
11701173

11711174
self.sled_add_zone(sled_id, zone)
@@ -1211,13 +1214,14 @@ impl<'a> BlueprintBuilder<'a> {
12111214
dns_address,
12121215
nic,
12131216
});
1217+
let image_source = self.zone_image_source(zone_type.kind());
12141218

12151219
let zone = BlueprintZoneConfig {
12161220
disposition: BlueprintZoneDisposition::InService,
12171221
id,
12181222
filesystem_pool: pool_name,
12191223
zone_type,
1220-
image_source: BlueprintZoneImageSource::InstallDataset,
1224+
image_source,
12211225
};
12221226
self.sled_add_zone(sled_id, zone)
12231227
}
@@ -1250,13 +1254,14 @@ impl<'a> BlueprintBuilder<'a> {
12501254
});
12511255
let filesystem_pool =
12521256
self.sled_select_zpool(sled_id, zone_type.kind())?;
1257+
let image_source = self.zone_image_source(zone_type.kind());
12531258

12541259
let zone = BlueprintZoneConfig {
12551260
disposition: BlueprintZoneDisposition::InService,
12561261
id: self.rng.sled_rng(sled_id).next_zone(),
12571262
filesystem_pool,
12581263
zone_type,
1259-
image_source: BlueprintZoneImageSource::InstallDataset,
1264+
image_source,
12601265
};
12611266

12621267
self.sled_add_zone(sled_id, zone)?;
@@ -1402,13 +1407,14 @@ impl<'a> BlueprintBuilder<'a> {
14021407
});
14031408
let filesystem_pool =
14041409
self.sled_select_zpool(sled_id, zone_type.kind())?;
1410+
let image_source = self.zone_image_source(zone_type.kind());
14051411

14061412
let zone = BlueprintZoneConfig {
14071413
disposition: BlueprintZoneDisposition::InService,
14081414
id: nexus_id,
14091415
filesystem_pool,
14101416
zone_type,
1411-
image_source: BlueprintZoneImageSource::InstallDataset,
1417+
image_source,
14121418
};
14131419
self.sled_add_zone(sled_id, zone)
14141420
}
@@ -1427,13 +1433,14 @@ impl<'a> BlueprintBuilder<'a> {
14271433
});
14281434
let filesystem_pool =
14291435
self.sled_select_zpool(sled_id, zone_type.kind())?;
1436+
let image_source = self.zone_image_source(zone_type.kind());
14301437

14311438
let zone = BlueprintZoneConfig {
14321439
disposition: BlueprintZoneDisposition::InService,
14331440
id: oximeter_id,
14341441
filesystem_pool,
14351442
zone_type,
1436-
image_source: BlueprintZoneImageSource::InstallDataset,
1443+
image_source,
14371444
};
14381445
self.sled_add_zone(sled_id, zone)
14391446
}
@@ -1451,13 +1458,14 @@ impl<'a> BlueprintBuilder<'a> {
14511458
);
14521459
let filesystem_pool =
14531460
self.sled_select_zpool(sled_id, zone_type.kind())?;
1461+
let image_source = self.zone_image_source(zone_type.kind());
14541462

14551463
let zone = BlueprintZoneConfig {
14561464
disposition: BlueprintZoneDisposition::InService,
14571465
id: pantry_id,
14581466
filesystem_pool,
14591467
zone_type,
1460-
image_source: BlueprintZoneImageSource::InstallDataset,
1468+
image_source,
14611469
};
14621470
self.sled_add_zone(sled_id, zone)
14631471
}
@@ -1485,13 +1493,14 @@ impl<'a> BlueprintBuilder<'a> {
14851493
dataset: OmicronZoneDataset { pool_name: pool_name.clone() },
14861494
});
14871495
let filesystem_pool = pool_name;
1496+
let image_source = self.zone_image_source(zone_type.kind());
14881497

14891498
let zone = BlueprintZoneConfig {
14901499
disposition: BlueprintZoneDisposition::InService,
14911500
id: zone_id,
14921501
filesystem_pool,
14931502
zone_type,
1494-
image_source: BlueprintZoneImageSource::InstallDataset,
1503+
image_source,
14951504
};
14961505
self.sled_add_zone(sled_id, zone)
14971506
}
@@ -1511,13 +1520,14 @@ impl<'a> BlueprintBuilder<'a> {
15111520
address,
15121521
dataset: OmicronZoneDataset { pool_name: pool_name.clone() },
15131522
});
1523+
let image_source = self.zone_image_source(zone_type.kind());
15141524

15151525
let zone = BlueprintZoneConfig {
15161526
disposition: BlueprintZoneDisposition::InService,
15171527
id,
15181528
filesystem_pool: pool_name,
15191529
zone_type,
1520-
image_source: BlueprintZoneImageSource::InstallDataset,
1530+
image_source,
15211531
};
15221532
self.sled_add_zone(sled_id, zone)
15231533
}
@@ -1539,13 +1549,14 @@ impl<'a> BlueprintBuilder<'a> {
15391549
},
15401550
);
15411551
let filesystem_pool = pool_name;
1552+
let image_source = self.zone_image_source(zone_type.kind());
15421553

15431554
let zone = BlueprintZoneConfig {
15441555
disposition: BlueprintZoneDisposition::InService,
15451556
id: zone_id,
15461557
filesystem_pool,
15471558
zone_type,
1548-
image_source: BlueprintZoneImageSource::InstallDataset,
1559+
image_source,
15491560
};
15501561
self.sled_add_zone(sled_id, zone)
15511562
}
@@ -1567,13 +1578,14 @@ impl<'a> BlueprintBuilder<'a> {
15671578
},
15681579
);
15691580
let filesystem_pool = pool_name;
1581+
let image_source = self.zone_image_source(zone_type.kind());
15701582

15711583
let zone = BlueprintZoneConfig {
15721584
disposition: BlueprintZoneDisposition::InService,
15731585
id: zone_id,
15741586
filesystem_pool,
15751587
zone_type,
1576-
image_source: BlueprintZoneImageSource::InstallDataset,
1588+
image_source,
15771589
};
15781590
self.sled_add_zone(sled_id, zone)
15791591
}
@@ -1693,6 +1705,7 @@ impl<'a> BlueprintBuilder<'a> {
16931705
});
16941706
let filesystem_pool =
16951707
self.sled_select_zpool(sled_id, zone_type.kind())?;
1708+
let image_source = self.zone_image_source(zone_type.kind());
16961709

16971710
self.sled_add_zone(
16981711
sled_id,
@@ -1701,7 +1714,7 @@ impl<'a> BlueprintBuilder<'a> {
17011714
id: new_zone_id,
17021715
filesystem_pool,
17031716
zone_type,
1704-
image_source: BlueprintZoneImageSource::InstallDataset,
1717+
image_source,
17051718
},
17061719
)
17071720
}
@@ -1889,6 +1902,36 @@ impl<'a> BlueprintBuilder<'a> {
18891902
) {
18901903
self.pending_mgs_updates.remove(baseboard_id);
18911904
}
1905+
1906+
/// Try to find an artifact in the release repo that contains an image
1907+
/// for a zone of the given kind. Defaults to the install dataset.
1908+
pub(crate) fn zone_image_source(
1909+
&self,
1910+
zone_kind: ZoneKind,
1911+
) -> BlueprintZoneImageSource {
1912+
self.input
1913+
.tuf_repo()
1914+
.and_then(|repo| {
1915+
repo.artifacts
1916+
.iter()
1917+
.find(|artifact| {
1918+
artifact
1919+
.id
1920+
.kind
1921+
.to_known()
1922+
.map(|kind| matches!(kind, KnownArtifactKind::Zone))
1923+
.unwrap_or(false)
1924+
&& artifact.id.name == zone_kind.artifact_name()
1925+
})
1926+
.map(|artifact| BlueprintZoneImageSource::Artifact {
1927+
version: BlueprintZoneImageVersion::Available {
1928+
version: artifact.id.version.clone(),
1929+
},
1930+
hash: artifact.hash,
1931+
})
1932+
})
1933+
.unwrap_or(BlueprintZoneImageSource::InstallDataset)
1934+
}
18921935
}
18931936

18941937
// Helper to validate that the system hasn't gone off the rails. There should

0 commit comments

Comments
 (0)