@@ -33,6 +33,7 @@ use nexus_types::deployment::BlueprintSledConfig;
33
33
use nexus_types:: deployment:: BlueprintZoneConfig ;
34
34
use nexus_types:: deployment:: BlueprintZoneDisposition ;
35
35
use nexus_types:: deployment:: BlueprintZoneImageSource ;
36
+ use nexus_types:: deployment:: BlueprintZoneImageVersion ;
36
37
use nexus_types:: deployment:: BlueprintZoneType ;
37
38
use nexus_types:: deployment:: ClickhouseClusterConfig ;
38
39
use nexus_types:: deployment:: CockroachDbPreserveDowngrade ;
@@ -82,6 +83,7 @@ use std::net::Ipv6Addr;
82
83
use std:: net:: SocketAddr ;
83
84
use std:: net:: SocketAddrV6 ;
84
85
use thiserror:: Error ;
86
+ use tufaceous_artifact:: KnownArtifactKind ;
85
87
86
88
use super :: ClickhouseZonesThatShouldBeRunning ;
87
89
use super :: clickhouse:: ClickhouseAllocator ;
@@ -1159,13 +1161,14 @@ impl<'a> BlueprintBuilder<'a> {
1159
1161
gz_address : dns_subnet. gz_address ( ) ,
1160
1162
gz_address_index,
1161
1163
} ) ;
1164
+ let image_source = self . zone_image_source ( zone_type. kind ( ) ) ;
1162
1165
1163
1166
let zone = BlueprintZoneConfig {
1164
1167
disposition : BlueprintZoneDisposition :: InService ,
1165
1168
id : self . rng . sled_rng ( sled_id) . next_zone ( ) ,
1166
1169
filesystem_pool : zpool,
1167
1170
zone_type,
1168
- image_source : BlueprintZoneImageSource :: InstallDataset ,
1171
+ image_source,
1169
1172
} ;
1170
1173
1171
1174
self . sled_add_zone ( sled_id, zone)
@@ -1211,13 +1214,14 @@ impl<'a> BlueprintBuilder<'a> {
1211
1214
dns_address,
1212
1215
nic,
1213
1216
} ) ;
1217
+ let image_source = self . zone_image_source ( zone_type. kind ( ) ) ;
1214
1218
1215
1219
let zone = BlueprintZoneConfig {
1216
1220
disposition : BlueprintZoneDisposition :: InService ,
1217
1221
id,
1218
1222
filesystem_pool : pool_name,
1219
1223
zone_type,
1220
- image_source : BlueprintZoneImageSource :: InstallDataset ,
1224
+ image_source,
1221
1225
} ;
1222
1226
self . sled_add_zone ( sled_id, zone)
1223
1227
}
@@ -1250,13 +1254,14 @@ impl<'a> BlueprintBuilder<'a> {
1250
1254
} ) ;
1251
1255
let filesystem_pool =
1252
1256
self . sled_select_zpool ( sled_id, zone_type. kind ( ) ) ?;
1257
+ let image_source = self . zone_image_source ( zone_type. kind ( ) ) ;
1253
1258
1254
1259
let zone = BlueprintZoneConfig {
1255
1260
disposition : BlueprintZoneDisposition :: InService ,
1256
1261
id : self . rng . sled_rng ( sled_id) . next_zone ( ) ,
1257
1262
filesystem_pool,
1258
1263
zone_type,
1259
- image_source : BlueprintZoneImageSource :: InstallDataset ,
1264
+ image_source,
1260
1265
} ;
1261
1266
1262
1267
self . sled_add_zone ( sled_id, zone) ?;
@@ -1402,13 +1407,14 @@ impl<'a> BlueprintBuilder<'a> {
1402
1407
} ) ;
1403
1408
let filesystem_pool =
1404
1409
self . sled_select_zpool ( sled_id, zone_type. kind ( ) ) ?;
1410
+ let image_source = self . zone_image_source ( zone_type. kind ( ) ) ;
1405
1411
1406
1412
let zone = BlueprintZoneConfig {
1407
1413
disposition : BlueprintZoneDisposition :: InService ,
1408
1414
id : nexus_id,
1409
1415
filesystem_pool,
1410
1416
zone_type,
1411
- image_source : BlueprintZoneImageSource :: InstallDataset ,
1417
+ image_source,
1412
1418
} ;
1413
1419
self . sled_add_zone ( sled_id, zone)
1414
1420
}
@@ -1427,13 +1433,14 @@ impl<'a> BlueprintBuilder<'a> {
1427
1433
} ) ;
1428
1434
let filesystem_pool =
1429
1435
self . sled_select_zpool ( sled_id, zone_type. kind ( ) ) ?;
1436
+ let image_source = self . zone_image_source ( zone_type. kind ( ) ) ;
1430
1437
1431
1438
let zone = BlueprintZoneConfig {
1432
1439
disposition : BlueprintZoneDisposition :: InService ,
1433
1440
id : oximeter_id,
1434
1441
filesystem_pool,
1435
1442
zone_type,
1436
- image_source : BlueprintZoneImageSource :: InstallDataset ,
1443
+ image_source,
1437
1444
} ;
1438
1445
self . sled_add_zone ( sled_id, zone)
1439
1446
}
@@ -1451,13 +1458,14 @@ impl<'a> BlueprintBuilder<'a> {
1451
1458
) ;
1452
1459
let filesystem_pool =
1453
1460
self . sled_select_zpool ( sled_id, zone_type. kind ( ) ) ?;
1461
+ let image_source = self . zone_image_source ( zone_type. kind ( ) ) ;
1454
1462
1455
1463
let zone = BlueprintZoneConfig {
1456
1464
disposition : BlueprintZoneDisposition :: InService ,
1457
1465
id : pantry_id,
1458
1466
filesystem_pool,
1459
1467
zone_type,
1460
- image_source : BlueprintZoneImageSource :: InstallDataset ,
1468
+ image_source,
1461
1469
} ;
1462
1470
self . sled_add_zone ( sled_id, zone)
1463
1471
}
@@ -1485,13 +1493,14 @@ impl<'a> BlueprintBuilder<'a> {
1485
1493
dataset : OmicronZoneDataset { pool_name : pool_name. clone ( ) } ,
1486
1494
} ) ;
1487
1495
let filesystem_pool = pool_name;
1496
+ let image_source = self . zone_image_source ( zone_type. kind ( ) ) ;
1488
1497
1489
1498
let zone = BlueprintZoneConfig {
1490
1499
disposition : BlueprintZoneDisposition :: InService ,
1491
1500
id : zone_id,
1492
1501
filesystem_pool,
1493
1502
zone_type,
1494
- image_source : BlueprintZoneImageSource :: InstallDataset ,
1503
+ image_source,
1495
1504
} ;
1496
1505
self . sled_add_zone ( sled_id, zone)
1497
1506
}
@@ -1511,13 +1520,14 @@ impl<'a> BlueprintBuilder<'a> {
1511
1520
address,
1512
1521
dataset : OmicronZoneDataset { pool_name : pool_name. clone ( ) } ,
1513
1522
} ) ;
1523
+ let image_source = self . zone_image_source ( zone_type. kind ( ) ) ;
1514
1524
1515
1525
let zone = BlueprintZoneConfig {
1516
1526
disposition : BlueprintZoneDisposition :: InService ,
1517
1527
id,
1518
1528
filesystem_pool : pool_name,
1519
1529
zone_type,
1520
- image_source : BlueprintZoneImageSource :: InstallDataset ,
1530
+ image_source,
1521
1531
} ;
1522
1532
self . sled_add_zone ( sled_id, zone)
1523
1533
}
@@ -1539,13 +1549,14 @@ impl<'a> BlueprintBuilder<'a> {
1539
1549
} ,
1540
1550
) ;
1541
1551
let filesystem_pool = pool_name;
1552
+ let image_source = self . zone_image_source ( zone_type. kind ( ) ) ;
1542
1553
1543
1554
let zone = BlueprintZoneConfig {
1544
1555
disposition : BlueprintZoneDisposition :: InService ,
1545
1556
id : zone_id,
1546
1557
filesystem_pool,
1547
1558
zone_type,
1548
- image_source : BlueprintZoneImageSource :: InstallDataset ,
1559
+ image_source,
1549
1560
} ;
1550
1561
self . sled_add_zone ( sled_id, zone)
1551
1562
}
@@ -1567,13 +1578,14 @@ impl<'a> BlueprintBuilder<'a> {
1567
1578
} ,
1568
1579
) ;
1569
1580
let filesystem_pool = pool_name;
1581
+ let image_source = self . zone_image_source ( zone_type. kind ( ) ) ;
1570
1582
1571
1583
let zone = BlueprintZoneConfig {
1572
1584
disposition : BlueprintZoneDisposition :: InService ,
1573
1585
id : zone_id,
1574
1586
filesystem_pool,
1575
1587
zone_type,
1576
- image_source : BlueprintZoneImageSource :: InstallDataset ,
1588
+ image_source,
1577
1589
} ;
1578
1590
self . sled_add_zone ( sled_id, zone)
1579
1591
}
@@ -1693,6 +1705,7 @@ impl<'a> BlueprintBuilder<'a> {
1693
1705
} ) ;
1694
1706
let filesystem_pool =
1695
1707
self . sled_select_zpool ( sled_id, zone_type. kind ( ) ) ?;
1708
+ let image_source = self . zone_image_source ( zone_type. kind ( ) ) ;
1696
1709
1697
1710
self . sled_add_zone (
1698
1711
sled_id,
@@ -1701,7 +1714,7 @@ impl<'a> BlueprintBuilder<'a> {
1701
1714
id : new_zone_id,
1702
1715
filesystem_pool,
1703
1716
zone_type,
1704
- image_source : BlueprintZoneImageSource :: InstallDataset ,
1717
+ image_source,
1705
1718
} ,
1706
1719
)
1707
1720
}
@@ -1889,6 +1902,36 @@ impl<'a> BlueprintBuilder<'a> {
1889
1902
) {
1890
1903
self . pending_mgs_updates . remove ( baseboard_id) ;
1891
1904
}
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
+ }
1892
1935
}
1893
1936
1894
1937
// Helper to validate that the system hasn't gone off the rails. There should
0 commit comments