@@ -39,6 +39,7 @@ use omicron_ddm_admin_client::DdmError;
3939use omicron_ddm_admin_client:: types:: EnableStatsRequest ;
4040use omicron_uuid_kinds:: GenericUuid ;
4141use omicron_uuid_kinds:: RackInitUuid ;
42+ use sled_agent_config_reconciler:: ConfigReconcilerSpawnToken ;
4243use sled_agent_config_reconciler:: InternalDisksReceiver ;
4344use sled_agent_types:: rack_init:: RackInitializeRequest ;
4445use sled_agent_types:: sled:: StartSledAgentRequest ;
@@ -180,6 +181,7 @@ impl Server {
180181 service_manager,
181182 long_running_task_handles,
182183 sled_agent_started_tx,
184+ config_reconciler_spawn_token,
183185 } = BootstrapAgentStartup :: run ( config) . await ?;
184186
185187 // Do we have a StartSledAgentRequest stored in the ledger?
@@ -246,6 +248,7 @@ impl Server {
246248 & config,
247249 start_sled_agent_request,
248250 long_running_task_handles. clone ( ) ,
251+ config_reconciler_spawn_token,
249252 service_manager. clone ( ) ,
250253 & base_log,
251254 & startup_log,
@@ -261,7 +264,10 @@ impl Server {
261264
262265 SledAgentState :: ServerStarted ( sled_agent_server)
263266 } 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+ } ) )
265271 } ;
266272
267273 // Spawn our inner task that handles any future hardware updates and any
@@ -303,11 +309,16 @@ impl Server {
303309// bootstrap server).
304310enum SledAgentState {
305311 // We're still in the bootstrapping phase, waiting for a sled-agent request.
306- Bootstrapping ( Option < oneshot :: Sender < SledAgent > > ) ,
312+ Bootstrapping ( Option < BootstrappingDependencies > ) ,
307313 // ... or the sled agent server is running.
308314 ServerStarted ( SledAgentServer ) ,
309315}
310316
317+ struct BootstrappingDependencies {
318+ sled_agent_started_tx : oneshot:: Sender < SledAgent > ,
319+ config_reconciler_spawn_token : ConfigReconcilerSpawnToken ,
320+ }
321+
311322#[ derive( thiserror:: Error , Debug ) ]
312323pub enum SledAgentServerStartError {
313324 #[ error( "Failed to start sled-agent server: {0}" ) ]
@@ -347,6 +358,7 @@ async fn start_sled_agent(
347358 config : & SledConfig ,
348359 request : StartSledAgentRequest ,
349360 long_running_task_handles : LongRunningTaskHandles ,
361+ config_reconciler_spawn_token : ConfigReconcilerSpawnToken ,
350362 service_manager : ServiceManager ,
351363 base_log : & Logger ,
352364 log : & Logger ,
@@ -398,6 +410,7 @@ async fn start_sled_agent(
398410 base_log. clone ( ) ,
399411 request. clone ( ) ,
400412 long_running_task_handles. clone ( ) ,
413+ config_reconciler_spawn_token,
401414 service_manager,
402415 )
403416 . await
@@ -531,7 +544,7 @@ impl Inner {
531544 log : & Logger ,
532545 ) {
533546 match & mut self . state {
534- SledAgentState :: Bootstrapping ( sled_agent_started_tx ) => {
547+ SledAgentState :: Bootstrapping ( deps ) => {
535548 let request_id = request. body . id . into_untyped_uuid ( ) ;
536549
537550 // Extract from options to satisfy the borrow checker.
@@ -540,13 +553,16 @@ impl Inner {
540553 // we explicitly unwrap here, and panic on error below.
541554 //
542555 // 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 ( ) ;
545560
546561 let response = match start_sled_agent (
547562 & self . config ,
548563 request,
549564 self . long_running_task_handles . clone ( ) ,
565+ config_reconciler_spawn_token,
550566 self . service_manager . clone ( ) ,
551567 & self . base_log ,
552568 & log,
0 commit comments