@@ -39,6 +39,7 @@ use omicron_ddm_admin_client::DdmError;
39
39
use omicron_ddm_admin_client:: types:: EnableStatsRequest ;
40
40
use omicron_uuid_kinds:: GenericUuid ;
41
41
use omicron_uuid_kinds:: RackInitUuid ;
42
+ use sled_agent_config_reconciler:: ConfigReconcilerSpawnToken ;
42
43
use sled_agent_config_reconciler:: InternalDisksReceiver ;
43
44
use sled_agent_types:: rack_init:: RackInitializeRequest ;
44
45
use sled_agent_types:: sled:: StartSledAgentRequest ;
@@ -180,6 +181,7 @@ impl Server {
180
181
service_manager,
181
182
long_running_task_handles,
182
183
sled_agent_started_tx,
184
+ config_reconciler_spawn_token,
183
185
} = BootstrapAgentStartup :: run ( config) . await ?;
184
186
185
187
// Do we have a StartSledAgentRequest stored in the ledger?
@@ -246,6 +248,7 @@ impl Server {
246
248
& config,
247
249
start_sled_agent_request,
248
250
long_running_task_handles. clone ( ) ,
251
+ config_reconciler_spawn_token,
249
252
service_manager. clone ( ) ,
250
253
& base_log,
251
254
& startup_log,
@@ -261,7 +264,10 @@ impl Server {
261
264
262
265
SledAgentState :: ServerStarted ( sled_agent_server)
263
266
} else {
264
- SledAgentState :: Bootstrapping ( Some ( sled_agent_started_tx) )
267
+ SledAgentState :: Bootstrapping ( Some ( BootstrappingDependencies {
268
+ sled_agent_started_tx,
269
+ config_reconciler_spawn_token,
270
+ } ) )
265
271
} ;
266
272
267
273
// Spawn our inner task that handles any future hardware updates and any
@@ -303,11 +309,16 @@ impl Server {
303
309
// bootstrap server).
304
310
enum SledAgentState {
305
311
// We're still in the bootstrapping phase, waiting for a sled-agent request.
306
- Bootstrapping ( Option < oneshot :: Sender < SledAgent > > ) ,
312
+ Bootstrapping ( Option < BootstrappingDependencies > ) ,
307
313
// ... or the sled agent server is running.
308
314
ServerStarted ( SledAgentServer ) ,
309
315
}
310
316
317
+ struct BootstrappingDependencies {
318
+ sled_agent_started_tx : oneshot:: Sender < SledAgent > ,
319
+ config_reconciler_spawn_token : ConfigReconcilerSpawnToken ,
320
+ }
321
+
311
322
#[ derive( thiserror:: Error , Debug ) ]
312
323
pub enum SledAgentServerStartError {
313
324
#[ error( "Failed to start sled-agent server: {0}" ) ]
@@ -347,6 +358,7 @@ async fn start_sled_agent(
347
358
config : & SledConfig ,
348
359
request : StartSledAgentRequest ,
349
360
long_running_task_handles : LongRunningTaskHandles ,
361
+ config_reconciler_spawn_token : ConfigReconcilerSpawnToken ,
350
362
service_manager : ServiceManager ,
351
363
base_log : & Logger ,
352
364
log : & Logger ,
@@ -398,6 +410,7 @@ async fn start_sled_agent(
398
410
base_log. clone ( ) ,
399
411
request. clone ( ) ,
400
412
long_running_task_handles. clone ( ) ,
413
+ config_reconciler_spawn_token,
401
414
service_manager,
402
415
)
403
416
. await
@@ -531,7 +544,7 @@ impl Inner {
531
544
log : & Logger ,
532
545
) {
533
546
match & mut self . state {
534
- SledAgentState :: Bootstrapping ( sled_agent_started_tx ) => {
547
+ SledAgentState :: Bootstrapping ( deps ) => {
535
548
let request_id = request. body . id . into_untyped_uuid ( ) ;
536
549
537
550
// Extract from options to satisfy the borrow checker.
@@ -540,13 +553,16 @@ impl Inner {
540
553
// we explicitly unwrap here, and panic on error below.
541
554
//
542
555
// See https://github.com/oxidecomputer/omicron/issues/4494
543
- let sled_agent_started_tx =
544
- sled_agent_started_tx. take ( ) . unwrap ( ) ;
556
+ let BootstrappingDependencies {
557
+ sled_agent_started_tx,
558
+ config_reconciler_spawn_token,
559
+ } = deps. take ( ) . unwrap ( ) ;
545
560
546
561
let response = match start_sled_agent (
547
562
& self . config ,
548
563
request,
549
564
self . long_running_task_handles . clone ( ) ,
565
+ config_reconciler_spawn_token,
550
566
self . service_manager . clone ( ) ,
551
567
& self . base_log ,
552
568
& log,
0 commit comments