@@ -45,6 +45,8 @@ use nexus_types::deployment::PendingMgsUpdates;
45
45
use nexus_types:: deployment:: PlanningInput ;
46
46
use nexus_types:: deployment:: SledFilter ;
47
47
use nexus_types:: deployment:: SledResources ;
48
+ use nexus_types:: deployment:: TargetReleaseDescription ;
49
+ use nexus_types:: deployment:: TufRepoContentsError ;
48
50
use nexus_types:: deployment:: ZpoolFilter ;
49
51
use nexus_types:: deployment:: ZpoolName ;
50
52
use nexus_types:: deployment:: blueprint_zone_type;
@@ -56,7 +58,6 @@ use omicron_common::address::DNS_PORT;
56
58
use omicron_common:: address:: NTP_PORT ;
57
59
use omicron_common:: address:: ReservedRackSubnet ;
58
60
use omicron_common:: api:: external:: Generation ;
59
- use omicron_common:: api:: external:: TufRepoDescription ;
60
61
use omicron_common:: api:: external:: Vni ;
61
62
use omicron_common:: api:: internal:: shared:: NetworkInterface ;
62
63
use omicron_common:: api:: internal:: shared:: NetworkInterfaceKind ;
@@ -135,6 +136,8 @@ pub enum Error {
135
136
expected : Generation ,
136
137
actual : Generation ,
137
138
} ,
139
+ #[ error( transparent) ]
140
+ TufRepoContentsError ( #[ from] TufRepoContentsError ) ,
138
141
}
139
142
140
143
/// Describes the result of an idempotent "ensure" operation
@@ -1179,7 +1182,7 @@ impl<'a> BlueprintBuilder<'a> {
1179
1182
gz_address : dns_subnet. gz_address ( ) ,
1180
1183
gz_address_index,
1181
1184
} ) ;
1182
- let image_source = self . zone_image_source ( zone_type. kind ( ) ) ;
1185
+ let image_source = self . zone_image_source ( zone_type. kind ( ) ) ? ;
1183
1186
1184
1187
let zone = BlueprintZoneConfig {
1185
1188
disposition : BlueprintZoneDisposition :: InService ,
@@ -1232,7 +1235,7 @@ impl<'a> BlueprintBuilder<'a> {
1232
1235
dns_address,
1233
1236
nic,
1234
1237
} ) ;
1235
- let image_source = self . zone_image_source ( zone_type. kind ( ) ) ;
1238
+ let image_source = self . zone_image_source ( zone_type. kind ( ) ) ? ;
1236
1239
1237
1240
let zone = BlueprintZoneConfig {
1238
1241
disposition : BlueprintZoneDisposition :: InService ,
@@ -1272,7 +1275,7 @@ impl<'a> BlueprintBuilder<'a> {
1272
1275
} ) ;
1273
1276
let filesystem_pool =
1274
1277
self . sled_select_zpool ( sled_id, zone_type. kind ( ) ) ?;
1275
- let image_source = self . zone_image_source ( zone_type. kind ( ) ) ;
1278
+ let image_source = self . zone_image_source ( zone_type. kind ( ) ) ? ;
1276
1279
1277
1280
let zone = BlueprintZoneConfig {
1278
1281
disposition : BlueprintZoneDisposition :: InService ,
@@ -1425,7 +1428,7 @@ impl<'a> BlueprintBuilder<'a> {
1425
1428
} ) ;
1426
1429
let filesystem_pool =
1427
1430
self . sled_select_zpool ( sled_id, zone_type. kind ( ) ) ?;
1428
- let image_source = self . zone_image_source ( zone_type. kind ( ) ) ;
1431
+ let image_source = self . zone_image_source ( zone_type. kind ( ) ) ? ;
1429
1432
1430
1433
let zone = BlueprintZoneConfig {
1431
1434
disposition : BlueprintZoneDisposition :: InService ,
@@ -1451,7 +1454,7 @@ impl<'a> BlueprintBuilder<'a> {
1451
1454
} ) ;
1452
1455
let filesystem_pool =
1453
1456
self . sled_select_zpool ( sled_id, zone_type. kind ( ) ) ?;
1454
- let image_source = self . zone_image_source ( zone_type. kind ( ) ) ;
1457
+ let image_source = self . zone_image_source ( zone_type. kind ( ) ) ? ;
1455
1458
1456
1459
let zone = BlueprintZoneConfig {
1457
1460
disposition : BlueprintZoneDisposition :: InService ,
@@ -1476,7 +1479,7 @@ impl<'a> BlueprintBuilder<'a> {
1476
1479
) ;
1477
1480
let filesystem_pool =
1478
1481
self . sled_select_zpool ( sled_id, zone_type. kind ( ) ) ?;
1479
- let image_source = self . zone_image_source ( zone_type. kind ( ) ) ;
1482
+ let image_source = self . zone_image_source ( zone_type. kind ( ) ) ? ;
1480
1483
1481
1484
let zone = BlueprintZoneConfig {
1482
1485
disposition : BlueprintZoneDisposition :: InService ,
@@ -1511,7 +1514,7 @@ impl<'a> BlueprintBuilder<'a> {
1511
1514
dataset : OmicronZoneDataset { pool_name } ,
1512
1515
} ) ;
1513
1516
let filesystem_pool = pool_name;
1514
- let image_source = self . zone_image_source ( zone_type. kind ( ) ) ;
1517
+ let image_source = self . zone_image_source ( zone_type. kind ( ) ) ? ;
1515
1518
1516
1519
let zone = BlueprintZoneConfig {
1517
1520
disposition : BlueprintZoneDisposition :: InService ,
@@ -1538,7 +1541,7 @@ impl<'a> BlueprintBuilder<'a> {
1538
1541
address,
1539
1542
dataset : OmicronZoneDataset { pool_name } ,
1540
1543
} ) ;
1541
- let image_source = self . zone_image_source ( zone_type. kind ( ) ) ;
1544
+ let image_source = self . zone_image_source ( zone_type. kind ( ) ) ? ;
1542
1545
1543
1546
let zone = BlueprintZoneConfig {
1544
1547
disposition : BlueprintZoneDisposition :: InService ,
@@ -1567,7 +1570,7 @@ impl<'a> BlueprintBuilder<'a> {
1567
1570
} ,
1568
1571
) ;
1569
1572
let filesystem_pool = pool_name;
1570
- let image_source = self . zone_image_source ( zone_type. kind ( ) ) ;
1573
+ let image_source = self . zone_image_source ( zone_type. kind ( ) ) ? ;
1571
1574
1572
1575
let zone = BlueprintZoneConfig {
1573
1576
disposition : BlueprintZoneDisposition :: InService ,
@@ -1596,7 +1599,7 @@ impl<'a> BlueprintBuilder<'a> {
1596
1599
} ,
1597
1600
) ;
1598
1601
let filesystem_pool = pool_name;
1599
- let image_source = self . zone_image_source ( zone_type. kind ( ) ) ;
1602
+ let image_source = self . zone_image_source ( zone_type. kind ( ) ) ? ;
1600
1603
1601
1604
let zone = BlueprintZoneConfig {
1602
1605
disposition : BlueprintZoneDisposition :: InService ,
@@ -1723,7 +1726,7 @@ impl<'a> BlueprintBuilder<'a> {
1723
1726
} ) ;
1724
1727
let filesystem_pool =
1725
1728
self . sled_select_zpool ( sled_id, zone_type. kind ( ) ) ?;
1726
- let image_source = self . zone_image_source ( zone_type. kind ( ) ) ;
1729
+ let image_source = self . zone_image_source ( zone_type. kind ( ) ) ? ;
1727
1730
1728
1731
self . sled_add_zone (
1729
1732
sled_id,
@@ -1981,39 +1984,22 @@ impl<'a> BlueprintBuilder<'a> {
1981
1984
self . pending_mgs_updates . remove ( baseboard_id) ;
1982
1985
}
1983
1986
1984
- fn zone_image_artifact (
1985
- repo : Option < & TufRepoDescription > ,
1986
- zone_kind : ZoneKind ,
1987
- ) -> BlueprintZoneImageSource {
1988
- repo. and_then ( |repo| {
1989
- repo. artifacts
1990
- . iter ( )
1991
- . find ( |artifact| {
1992
- zone_kind. is_control_plane_zone_artifact ( & artifact. id )
1993
- } )
1994
- . map ( BlueprintZoneImageSource :: from_available_artifact)
1995
- } )
1996
- . unwrap_or ( BlueprintZoneImageSource :: InstallDataset )
1997
- }
1998
-
1999
1987
/// Try to find an artifact in either the current or previous release repo
2000
1988
/// that contains an image for a zone of the given kind; see RFD 565 §9.
2001
1989
/// Defaults to the install dataset.
2002
1990
pub ( crate ) fn zone_image_source (
2003
1991
& self ,
2004
1992
zone_kind : ZoneKind ,
2005
- ) -> BlueprintZoneImageSource {
1993
+ ) -> Result < BlueprintZoneImageSource , TufRepoContentsError > {
2006
1994
let new_repo = self . input . tuf_repo ( ) . description ( ) ;
2007
- let old_repo =
2008
- self . input . old_repo ( ) . and_then ( |repo| repo. description ( ) ) ;
2009
- Self :: zone_image_artifact (
2010
- if self . zone_is_ready_for_update ( zone_kind, new_repo) {
2011
- new_repo
2012
- } else {
2013
- old_repo
2014
- } ,
2015
- zone_kind,
2016
- )
1995
+ let old_repo = self . input . old_repo ( ) . description ( ) ;
1996
+ let repo_choice = if self . zone_is_ready_for_update ( zone_kind, new_repo)
1997
+ {
1998
+ new_repo
1999
+ } else {
2000
+ old_repo
2001
+ } ;
2002
+ repo_choice. zone_image_source ( zone_kind)
2017
2003
}
2018
2004
2019
2005
/// Return `true` iff a zone of the given kind is ready to be updated;
@@ -2022,7 +2008,7 @@ impl<'a> BlueprintBuilder<'a> {
2022
2008
fn zone_is_ready_for_update (
2023
2009
& self ,
2024
2010
zone_kind : ZoneKind ,
2025
- new_repo : Option < & TufRepoDescription > ,
2011
+ new_repo : & TargetReleaseDescription ,
2026
2012
) -> bool {
2027
2013
match zone_kind {
2028
2014
ZoneKind :: Nexus => {
@@ -2035,8 +2021,15 @@ impl<'a> BlueprintBuilder<'a> {
2035
2021
)
2036
2022
. filter ( |z| z. zone_type . kind ( ) != ZoneKind :: Nexus )
2037
2023
. all ( |z| {
2038
- z. image_source
2039
- == Self :: zone_image_artifact ( new_repo, z. kind ( ) )
2024
+ // This comparison ignores any TUF repo contents errors
2025
+ // from `zone_image_source`. This means we'll never be
2026
+ // able to update Nexus if we can't tell if _other_ zone
2027
+ // types aren't updated, which seems correct.
2028
+ Some ( & z. image_source )
2029
+ == new_repo
2030
+ . zone_image_source ( z. kind ( ) )
2031
+ . ok ( )
2032
+ . as_ref ( )
2040
2033
} )
2041
2034
} )
2042
2035
}
0 commit comments