@@ -288,7 +288,9 @@ impl Plan {
288
288
}
289
289
290
290
// We'll stripe most services across all available Sleds, round-robin
291
- // style. In development and CI, this might only be one Sled.
291
+ // style. In development and CI, this might only be one Sled. We'll
292
+ // only report `NotEnoughSleds` below if there are zero Sleds or if we
293
+ // ran out of zpools on the available Sleds.
292
294
let mut sled_allocator = ( 0 ..sled_info. len ( ) ) . cycle ( ) ;
293
295
294
296
// Provision internal DNS zones, striping across Sleds.
@@ -302,7 +304,8 @@ impl Plan {
302
304
for dns_subnet in & dns_subnets {
303
305
let ip = dns_subnet. dns_address ( ) . ip ( ) ;
304
306
let sled = {
305
- let which_sled = sled_allocator. next ( ) . unwrap ( ) ;
307
+ let which_sled =
308
+ sled_allocator. next ( ) . ok_or ( PlanError :: NotEnoughSleds ) ?;
306
309
& mut sled_info[ which_sled]
307
310
} ;
308
311
let http_address = SocketAddrV6 :: new ( ip, DNS_HTTP_PORT , 0 , 0 ) ;
@@ -339,7 +342,8 @@ impl Plan {
339
342
// Provision CockroachDB zones, continuing to stripe across Sleds.
340
343
for _ in 0 ..CRDB_COUNT {
341
344
let sled = {
342
- let which_sled = sled_allocator. next ( ) . unwrap ( ) ;
345
+ let which_sled =
346
+ sled_allocator. next ( ) . ok_or ( PlanError :: NotEnoughSleds ) ?;
343
347
& mut sled_info[ which_sled]
344
348
} ;
345
349
let id = Uuid :: new_v4 ( ) ;
@@ -367,7 +371,8 @@ impl Plan {
367
371
// Provision Nexus zones, continuing to stripe across sleds.
368
372
for _ in 0 ..NEXUS_COUNT {
369
373
let sled = {
370
- let which_sled = sled_allocator. next ( ) . unwrap ( ) ;
374
+ let which_sled =
375
+ sled_allocator. next ( ) . ok_or ( PlanError :: NotEnoughSleds ) ?;
371
376
& mut sled_info[ which_sled]
372
377
} ;
373
378
let id = Uuid :: new_v4 ( ) ;
@@ -410,7 +415,8 @@ impl Plan {
410
415
// TODO(https://github.com/oxidecomputer/omicron/issues/732): Remove
411
416
for _ in 0 ..EXTERNAL_DNS_COUNT {
412
417
let sled = {
413
- let which_sled = sled_allocator. next ( ) . unwrap ( ) ;
418
+ let which_sled =
419
+ sled_allocator. next ( ) . ok_or ( PlanError :: NotEnoughSleds ) ?;
414
420
& mut sled_info[ which_sled]
415
421
} ;
416
422
let internal_ip = sled. addr_alloc . next ( ) . expect ( "Not enough addrs" ) ;
@@ -453,7 +459,8 @@ impl Plan {
453
459
// TODO(https://github.com/oxidecomputer/omicron/issues/732): Remove
454
460
for _ in 0 ..OXIMETER_COUNT {
455
461
let sled = {
456
- let which_sled = sled_allocator. next ( ) . unwrap ( ) ;
462
+ let which_sled =
463
+ sled_allocator. next ( ) . ok_or ( PlanError :: NotEnoughSleds ) ?;
457
464
& mut sled_info[ which_sled]
458
465
} ;
459
466
let id = Uuid :: new_v4 ( ) ;
@@ -483,7 +490,8 @@ impl Plan {
483
490
// TODO(https://github.com/oxidecomputer/omicron/issues/732): Remove
484
491
for _ in 0 ..CLICKHOUSE_COUNT {
485
492
let sled = {
486
- let which_sled = sled_allocator. next ( ) . unwrap ( ) ;
493
+ let which_sled =
494
+ sled_allocator. next ( ) . ok_or ( PlanError :: NotEnoughSleds ) ?;
487
495
& mut sled_info[ which_sled]
488
496
} ;
489
497
let id = Uuid :: new_v4 ( ) ;
@@ -512,7 +520,8 @@ impl Plan {
512
520
// TODO(https://github.com/oxidecomputer/omicron/issues/732): Remove
513
521
for _ in 0 ..PANTRY_COUNT {
514
522
let sled = {
515
- let which_sled = sled_allocator. next ( ) . unwrap ( ) ;
523
+ let which_sled =
524
+ sled_allocator. next ( ) . ok_or ( PlanError :: NotEnoughSleds ) ?;
516
525
& mut sled_info[ which_sled]
517
526
} ;
518
527
let address = sled. addr_alloc . next ( ) . expect ( "Not enough addrs" ) ;
0 commit comments