@@ -288,7 +288,9 @@ impl Plan {
288288 }
289289
290290 // 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.
292294 let mut sled_allocator = ( 0 ..sled_info. len ( ) ) . cycle ( ) ;
293295
294296 // Provision internal DNS zones, striping across Sleds.
@@ -302,7 +304,8 @@ impl Plan {
302304 for dns_subnet in & dns_subnets {
303305 let ip = dns_subnet. dns_address ( ) . ip ( ) ;
304306 let sled = {
305- let which_sled = sled_allocator. next ( ) . unwrap ( ) ;
307+ let which_sled =
308+ sled_allocator. next ( ) . ok_or ( PlanError :: NotEnoughSleds ) ?;
306309 & mut sled_info[ which_sled]
307310 } ;
308311 let http_address = SocketAddrV6 :: new ( ip, DNS_HTTP_PORT , 0 , 0 ) ;
@@ -339,7 +342,8 @@ impl Plan {
339342 // Provision CockroachDB zones, continuing to stripe across Sleds.
340343 for _ in 0 ..CRDB_COUNT {
341344 let sled = {
342- let which_sled = sled_allocator. next ( ) . unwrap ( ) ;
345+ let which_sled =
346+ sled_allocator. next ( ) . ok_or ( PlanError :: NotEnoughSleds ) ?;
343347 & mut sled_info[ which_sled]
344348 } ;
345349 let id = Uuid :: new_v4 ( ) ;
@@ -367,7 +371,8 @@ impl Plan {
367371 // Provision Nexus zones, continuing to stripe across sleds.
368372 for _ in 0 ..NEXUS_COUNT {
369373 let sled = {
370- let which_sled = sled_allocator. next ( ) . unwrap ( ) ;
374+ let which_sled =
375+ sled_allocator. next ( ) . ok_or ( PlanError :: NotEnoughSleds ) ?;
371376 & mut sled_info[ which_sled]
372377 } ;
373378 let id = Uuid :: new_v4 ( ) ;
@@ -410,7 +415,8 @@ impl Plan {
410415 // TODO(https://github.com/oxidecomputer/omicron/issues/732): Remove
411416 for _ in 0 ..EXTERNAL_DNS_COUNT {
412417 let sled = {
413- let which_sled = sled_allocator. next ( ) . unwrap ( ) ;
418+ let which_sled =
419+ sled_allocator. next ( ) . ok_or ( PlanError :: NotEnoughSleds ) ?;
414420 & mut sled_info[ which_sled]
415421 } ;
416422 let internal_ip = sled. addr_alloc . next ( ) . expect ( "Not enough addrs" ) ;
@@ -453,7 +459,8 @@ impl Plan {
453459 // TODO(https://github.com/oxidecomputer/omicron/issues/732): Remove
454460 for _ in 0 ..OXIMETER_COUNT {
455461 let sled = {
456- let which_sled = sled_allocator. next ( ) . unwrap ( ) ;
462+ let which_sled =
463+ sled_allocator. next ( ) . ok_or ( PlanError :: NotEnoughSleds ) ?;
457464 & mut sled_info[ which_sled]
458465 } ;
459466 let id = Uuid :: new_v4 ( ) ;
@@ -483,7 +490,8 @@ impl Plan {
483490 // TODO(https://github.com/oxidecomputer/omicron/issues/732): Remove
484491 for _ in 0 ..CLICKHOUSE_COUNT {
485492 let sled = {
486- let which_sled = sled_allocator. next ( ) . unwrap ( ) ;
493+ let which_sled =
494+ sled_allocator. next ( ) . ok_or ( PlanError :: NotEnoughSleds ) ?;
487495 & mut sled_info[ which_sled]
488496 } ;
489497 let id = Uuid :: new_v4 ( ) ;
@@ -512,7 +520,8 @@ impl Plan {
512520 // TODO(https://github.com/oxidecomputer/omicron/issues/732): Remove
513521 for _ in 0 ..PANTRY_COUNT {
514522 let sled = {
515- let which_sled = sled_allocator. next ( ) . unwrap ( ) ;
523+ let which_sled =
524+ sled_allocator. next ( ) . ok_or ( PlanError :: NotEnoughSleds ) ?;
516525 & mut sled_info[ which_sled]
517526 } ;
518527 let address = sled. addr_alloc . next ( ) . expect ( "Not enough addrs" ) ;
0 commit comments