@@ -95,6 +95,7 @@ use slog::{Logger, debug, error, o};
95
95
use std:: collections:: BTreeMap ;
96
96
use std:: collections:: HashMap ;
97
97
use std:: fmt:: Debug ;
98
+ use std:: iter:: { once, repeat, zip} ;
98
99
use std:: net:: { IpAddr , Ipv4Addr , Ipv6Addr , SocketAddr , SocketAddrV6 } ;
99
100
use std:: sync:: Arc ;
100
101
use std:: time:: Duration ;
@@ -394,6 +395,8 @@ pub struct ControlPlaneTestContextBuilder<'a, N: NexusServer> {
394
395
pub internal_dns : Option < dns_server:: TransientServer > ,
395
396
dns_config : Option < DnsConfigParams > ,
396
397
initial_blueprint_id : Option < BlueprintUuid > ,
398
+ blueprint_disks : BTreeMap < SledUuid , IdMap < BlueprintPhysicalDiskConfig > > ,
399
+ blueprint_datasets : BTreeMap < SledUuid , IdMap < BlueprintDatasetConfig > > ,
397
400
blueprint_zones : Vec < BlueprintZoneConfig > ,
398
401
399
402
pub silo_name : Option < Name > ,
@@ -442,6 +445,8 @@ impl<'a, N: NexusServer> ControlPlaneTestContextBuilder<'a, N> {
442
445
internal_dns : None ,
443
446
dns_config : None ,
444
447
initial_blueprint_id : None ,
448
+ blueprint_disks : BTreeMap :: new ( ) ,
449
+ blueprint_datasets : BTreeMap :: new ( ) ,
445
450
blueprint_zones : Vec :: new ( ) ,
446
451
silo_name : None ,
447
452
user_name : None ,
@@ -843,7 +848,7 @@ impl<'a, N: NexusServer> ControlPlaneTestContextBuilder<'a, N> {
843
848
self . dns_config = Some ( dns_config) ;
844
849
}
845
850
846
- // Perform RSS handoff
851
+ /// Perform RSS handoff
847
852
pub async fn start_nexus_external (
848
853
& mut self ,
849
854
tls_certificates : Vec < Certificate > ,
@@ -881,11 +886,11 @@ impl<'a, N: NexusServer> ControlPlaneTestContextBuilder<'a, N> {
881
886
// The first sled agent is the only one that'll have configured
882
887
// blueprint zones, but the others all need to have disks.
883
888
884
- let maybe_zones = std :: iter :: once ( Some ( & self . blueprint_zones ) )
885
- . chain ( std :: iter :: repeat ( None ) ) ;
889
+ let maybe_zones =
890
+ once ( Some ( & self . blueprint_zones ) ) . chain ( repeat ( None ) ) ;
886
891
887
892
for ( sled_agent, maybe_zones) in
888
- std :: iter :: zip ( self . sled_agents . iter ( ) , maybe_zones)
893
+ zip ( self . sled_agents . iter ( ) , maybe_zones)
889
894
{
890
895
let sled_id = sled_agent. sled_agent_id ( ) ;
891
896
@@ -947,11 +952,13 @@ impl<'a, N: NexusServer> ControlPlaneTestContextBuilder<'a, N> {
947
952
}
948
953
}
949
954
955
+ self . blueprint_disks . insert ( sled_id, disks. clone ( ) ) ;
956
+ self . blueprint_datasets . insert ( sled_id, datasets. clone ( ) ) ;
950
957
blueprint_sleds. insert (
951
958
sled_id,
952
959
BlueprintSledConfig {
953
960
state : SledState :: Active ,
954
- sled_agent_generation : Generation :: new ( ) . next ( ) ,
961
+ sled_agent_generation : 4 . into ( ) ,
955
962
disks,
956
963
datasets,
957
964
zones,
@@ -1099,33 +1106,6 @@ impl<'a, N: NexusServer> ControlPlaneTestContextBuilder<'a, N> {
1099
1106
/// tell the other Sled Agents to report they have no zones configured, and
1100
1107
/// write the early network config to all sleds.
1101
1108
pub async fn configure_sled_agents ( & mut self ) {
1102
- let Some ( sled_agent) = self . sled_agents . first ( ) else {
1103
- panic ! ( "expected sled agent has not been created" ) ;
1104
- } ;
1105
-
1106
- let client = sled_agent_client:: Client :: new (
1107
- & format ! ( "http://{}" , sled_agent. local_addr( ) ) ,
1108
- self . logctx . log . clone ( ) ,
1109
- ) ;
1110
-
1111
- client
1112
- . omicron_config_put ( & OmicronSledConfig {
1113
- generation : Generation :: new ( ) . next ( ) ,
1114
- // Sending no disks or datasets is probably wrong, but there are
1115
- // a lot of inconsistencies with this in nexus-test.
1116
- disks : IdMap :: default ( ) ,
1117
- datasets : IdMap :: default ( ) ,
1118
- zones : self
1119
- . blueprint_zones
1120
- . clone ( )
1121
- . into_iter ( )
1122
- . map ( From :: from)
1123
- . collect ( ) ,
1124
- remove_mupdate_override : None ,
1125
- } )
1126
- . await
1127
- . expect ( "Failed to configure sled agent with our zones" ) ;
1128
-
1129
1109
let early_network_config = EarlyNetworkConfig {
1130
1110
body : EarlyNetworkConfigBody {
1131
1111
ntp_servers : Vec :: new ( ) ,
@@ -1142,33 +1122,40 @@ impl<'a, N: NexusServer> ControlPlaneTestContextBuilder<'a, N> {
1142
1122
schema_version : 2 ,
1143
1123
} ;
1144
1124
1145
- client
1146
- . write_network_bootstore_config ( & early_network_config)
1147
- . await
1148
- . expect ( "Failed to write early networking config to bootstore" ) ;
1125
+ macro_rules! from_clone {
1126
+ ( $source: expr) => {
1127
+ $source. clone( ) . into_iter( ) . map( From :: from) . collect( )
1128
+ } ;
1129
+ }
1149
1130
1150
- for sled_agent in self . sled_agents . iter ( ) . skip ( 1 ) {
1131
+ let generation = Generation :: from_u32 ( 2 ) ;
1132
+ let zones =
1133
+ once ( from_clone ! ( self . blueprint_zones) ) . chain ( repeat ( vec ! [ ] ) ) ;
1134
+ for ( sled_agent, sled_zones) in zip ( self . sled_agents . iter ( ) , zones) {
1135
+ let sled_id = sled_agent. sled_agent_id ( ) ;
1151
1136
let client = sled_agent_client:: Client :: new (
1152
1137
& format ! ( "http://{}" , sled_agent. local_addr( ) ) ,
1153
1138
self . logctx . log . clone ( ) ,
1154
1139
) ;
1155
1140
1156
1141
client
1157
1142
. omicron_config_put ( & OmicronSledConfig {
1158
- generation : Generation :: new ( ) . next ( ) ,
1159
- // As above, sending no disks or datasets is probably wrong
1160
- disks : IdMap :: default ( ) ,
1161
- datasets : IdMap :: default ( ) ,
1162
- zones : IdMap :: default ( ) ,
1143
+ generation,
1144
+ disks : from_clone ! ( self . blueprint_disks[ & sled_id] ) ,
1145
+ datasets : from_clone ! ( self . blueprint_datasets[ & sled_id] ) ,
1146
+ zones : sled_zones. into_iter ( ) . collect ( ) ,
1163
1147
remove_mupdate_override : None ,
1164
1148
} )
1165
1149
. await
1166
- . expect ( "Failed to configure sled agent with our zones" ) ;
1150
+ . expect ( "Failed to configure sled agent {sled_id} with zones" ) ;
1167
1151
1168
1152
client
1169
1153
. write_network_bootstore_config ( & early_network_config)
1170
1154
. await
1171
- . expect ( "Failed to write early networking config to bootstore" ) ;
1155
+ . expect (
1156
+ "Failed to write early networking config \
1157
+ to bootstore on sled {sled_id}",
1158
+ ) ;
1172
1159
}
1173
1160
}
1174
1161
@@ -1741,7 +1728,7 @@ async fn setup_with_config_impl<N: NexusServer>(
1741
1728
}
1742
1729
1743
1730
// Start expected services: these will all be allocated to the first sled
1744
- // agent. Afterwards, configure the first sled agent, and start the rest of
1731
+ // agent. Afterwards, configure the sled agents and start the rest of the
1745
1732
// the required services.
1746
1733
1747
1734
builder
@@ -1761,10 +1748,6 @@ async fn setup_with_config_impl<N: NexusServer>(
1761
1748
"populate_internal_dns" ,
1762
1749
Box :: new( |builder| builder. populate_internal_dns( ) . boxed( ) ) ,
1763
1750
) ,
1764
- (
1765
- "configure_sled_agents" ,
1766
- Box :: new( |builder| builder. configure_sled_agents( ) . boxed( ) ) ,
1767
- ) ,
1768
1751
(
1769
1752
"start_nexus_external" ,
1770
1753
Box :: new( |builder| {
@@ -1775,6 +1758,10 @@ async fn setup_with_config_impl<N: NexusServer>(
1775
1758
. boxed( )
1776
1759
} ) ,
1777
1760
) ,
1761
+ (
1762
+ "configure_sled_agents" ,
1763
+ Box :: new( |builder| builder. configure_sled_agents( ) . boxed( ) ) ,
1764
+ ) ,
1778
1765
(
1779
1766
"start_oximeter" ,
1780
1767
Box :: new( |builder| builder. start_oximeter( ) . boxed( ) ) ,
0 commit comments