@@ -117,6 +117,8 @@ pub enum SledEditError {
117
117
ZoneOnNonexistentZpool { zone_id : OmicronZoneUuid , zpool : ZpoolName } ,
118
118
#[ error( "ran out of underlay IP addresses" ) ]
119
119
OutOfUnderlayIps ,
120
+ #[ error( "cannot add zone with invalid underlay IP" ) ]
121
+ AddZoneBadUnderlayIp ( #[ source] SledUnderlayIpOutOfRange ) ,
120
122
}
121
123
122
124
#[ derive( Debug ) ]
@@ -350,18 +352,9 @@ impl ActiveSledEditor {
350
352
// dispositions. If a zone has been fully removed from the blueprint
351
353
// some time after expungement, we may reuse its IP; reconfigurator must
352
354
// know that's safe prior to pruning the expunged zone.
353
- let zone_ips = zones. zones ( BlueprintZoneFilter :: All ) . filter_map ( |z| {
354
- // Internal DNS zone's IPs are (intentionally!) outside the sled
355
- // subnet, and must be allocated across the rack as a whole. We'll
356
- // ignore any internal DNS zones when constructing our underlay IP
357
- // allocator (as `SledUnderlayIpAllocator` will fail if we tell it a
358
- // zone is using an IP outside of the sled subnet).
359
- if z. zone_type . is_internal_dns ( ) {
360
- None
361
- } else {
362
- Some ( ( z. zone_type . kind ( ) , z. underlay_ip ( ) ) )
363
- }
364
- } ) ;
355
+ let zone_ips = zones
356
+ . zones ( BlueprintZoneFilter :: All )
357
+ . map ( |z| ( z. zone_type . kind ( ) , z. underlay_ip ( ) ) ) ;
365
358
366
359
Ok ( Self {
367
360
underlay_ip_allocator : SledUnderlayIpAllocator :: new (
@@ -542,6 +535,13 @@ impl ActiveSledEditor {
542
535
// Ensure we can construct the configs for the datasets for this zone.
543
536
let datasets = ZoneDatasetConfigs :: new ( & self . disks , & zone) ?;
544
537
538
+ // Ensure this zone's IP is within our subnet and that future IP
539
+ // allocations take it into account. (Unless `zone` is an internal DNS
540
+ // zone, in which case validation is higher-level planner's job.)
541
+ self . underlay_ip_allocator
542
+ . mark_as_allocated ( zone. zone_type . kind ( ) , zone. underlay_ip ( ) )
543
+ . map_err ( SledEditError :: AddZoneBadUnderlayIp ) ?;
544
+
545
545
// Actually add the zone and its datasets.
546
546
self . zones . add_zone ( zone) ?;
547
547
datasets. ensure_in_service ( & mut self . datasets , rng) ;
0 commit comments