@@ -1489,9 +1489,6 @@ mod test {
1489
1489
assert_eq ! ( is_internal, Ok ( false ) ) ;
1490
1490
1491
1491
// now link it to the current silo, and it is still not internal.
1492
- //
1493
- // We're only making the IPv4 pool the default right now. See
1494
- // https://github.com/oxidecomputer/omicron/issues/8884 for more.
1495
1492
let silo_id = opctx. authn . silo_required ( ) . unwrap ( ) . id ( ) ;
1496
1493
let is_default = matches ! ( version, IpVersion :: V4 ) ;
1497
1494
let link = IpPoolResource {
@@ -1514,6 +1511,76 @@ mod test {
1514
1511
logctx. cleanup_successful ( ) ;
1515
1512
}
1516
1513
1514
+ #[ tokio:: test]
1515
+ async fn cannot_set_default_ip_pool_for_internal_silo ( ) {
1516
+ let logctx =
1517
+ dev:: test_setup_log ( "cannot_set_default_ip_pool_for_internal_silo" ) ;
1518
+ let db = TestDatabase :: new_with_datastore ( & logctx. log ) . await ;
1519
+ let ( opctx, datastore) = ( db. opctx ( ) , db. datastore ( ) ) ;
1520
+
1521
+ for version in [ IpVersion :: V4 , IpVersion :: V6 ] {
1522
+ // confirm internal pools appear as internal
1523
+ let ( authz_pool, pool) = datastore
1524
+ . ip_pools_service_lookup ( & opctx, version)
1525
+ . await
1526
+ . unwrap ( ) ;
1527
+ assert_eq ! ( pool. ip_version, version) ;
1528
+
1529
+ let is_internal =
1530
+ datastore. ip_pool_is_internal ( & opctx, & authz_pool) . await ;
1531
+ assert_eq ! ( is_internal, Ok ( true ) ) ;
1532
+
1533
+ // Try to link it as the default.
1534
+ let ( authz_silo, ..) =
1535
+ nexus_db_lookup:: LookupPath :: new ( & opctx, datastore)
1536
+ . silo_id ( nexus_types:: silo:: INTERNAL_SILO_ID )
1537
+ . lookup_for ( authz:: Action :: Read )
1538
+ . await
1539
+ . expect ( "Should be able to lookup internal silo" ) ;
1540
+ let link = IpPoolResource {
1541
+ ip_pool_id : authz_pool. id ( ) ,
1542
+ resource_type : IpPoolResourceType :: Silo ,
1543
+ resource_id : authz_silo. id ( ) ,
1544
+ is_default : true ,
1545
+ } ;
1546
+ let Err ( e) = datastore. ip_pool_link_silo ( opctx, link. clone ( ) ) . await
1547
+ else {
1548
+ panic ! (
1549
+ "should have failed to link IP Pool to internal silo as a default"
1550
+ ) ;
1551
+ } ;
1552
+ let Error :: InternalError { internal_message } = & e else {
1553
+ panic ! ( "should have received an internal error" ) ;
1554
+ } ;
1555
+ assert ! (
1556
+ internal_message. contains( "failed to satisfy CHECK constraint" )
1557
+ ) ;
1558
+
1559
+ // We can link it if it's not the default.
1560
+ let link = IpPoolResource { is_default : false , ..link } ;
1561
+ datastore. ip_pool_link_silo ( opctx, link) . await . expect (
1562
+ "Should be able to link non-default pool to internal silo" ,
1563
+ ) ;
1564
+
1565
+ // Try to set it to the default, and ensure that this also fails.
1566
+ let Err ( e) = datastore
1567
+ . ip_pool_set_default ( opctx, & authz_pool, & authz_silo, true )
1568
+ . await
1569
+ else {
1570
+ panic ! ( "should have failed to set internal pool to default" ) ;
1571
+ } ;
1572
+ let Error :: InternalError { internal_message } = & e else {
1573
+ panic ! ( "should have received an internal error" ) ;
1574
+ } ;
1575
+ assert ! (
1576
+ internal_message. contains( "failed to satisfy CHECK constraint" )
1577
+ ) ;
1578
+ }
1579
+
1580
+ db. terminate ( ) . await ;
1581
+ logctx. cleanup_successful ( ) ;
1582
+ }
1583
+
1517
1584
// We're breaking out the utilization tests for IPv4 and IPv6 pools, since
1518
1585
// pools only contain one version now.
1519
1586
//
0 commit comments