@@ -418,38 +418,12 @@ impl BackgroundTasksInitializer {
418
418
} ;
419
419
420
420
// Background task: blueprint loader
421
+ //
422
+ // Registration is below so that it can watch the planner.
421
423
let blueprint_loader =
422
424
blueprint_load:: TargetBlueprintLoader :: new ( datastore. clone ( ) ) ;
423
425
let rx_blueprint = blueprint_loader. watcher ( ) ;
424
426
425
- // Background task: blueprint planner
426
- let blueprint_planner = blueprint_planner:: BlueprintPlanner :: new (
427
- datastore. clone ( ) ,
428
- false ,
429
- rx_blueprint. clone ( ) ,
430
- ) ;
431
- let rx_planner = blueprint_planner. watcher ( ) ;
432
- driver. register ( TaskDefinition {
433
- name : "blueprint_planner" ,
434
- description : "Updates the target blueprint" ,
435
- period : config. blueprints . period_secs_plan ,
436
- task_impl : Box :: new ( blueprint_planner) ,
437
- opctx : opctx. child ( BTreeMap :: new ( ) ) ,
438
- watchers : vec ! [ Box :: new( rx_blueprint. clone( ) ) ] ,
439
- activator : task_blueprint_planner,
440
- } ) ;
441
-
442
- // The planner notifies the loader when it has generated a new target blueprint.
443
- driver. register ( TaskDefinition {
444
- name : "blueprint_loader" ,
445
- description : "Loads the current target blueprint from the DB" ,
446
- period : config. blueprints . period_secs_load ,
447
- task_impl : Box :: new ( blueprint_loader) ,
448
- opctx : opctx. child ( BTreeMap :: new ( ) ) ,
449
- watchers : vec ! [ Box :: new( rx_planner. clone( ) ) ] ,
450
- activator : task_blueprint_loader,
451
- } ) ;
452
-
453
427
// Background task: blueprint executor
454
428
let blueprint_executor = blueprint_execution:: BlueprintExecutor :: new (
455
429
datastore. clone ( ) ,
@@ -470,22 +444,6 @@ impl BackgroundTasksInitializer {
470
444
activator : task_blueprint_executor,
471
445
} ) ;
472
446
473
- // Background task: CockroachDB node ID collector
474
- let crdb_node_id_collector =
475
- crdb_node_id_collector:: CockroachNodeIdCollector :: new (
476
- datastore. clone ( ) ,
477
- rx_blueprint. clone ( ) ,
478
- ) ;
479
- driver. register ( TaskDefinition {
480
- name : "crdb_node_id_collector" ,
481
- description : "Collects node IDs of running CockroachDB zones" ,
482
- period : config. blueprints . period_secs_collect_crdb_node_ids ,
483
- task_impl : Box :: new ( crdb_node_id_collector) ,
484
- opctx : opctx. child ( BTreeMap :: new ( ) ) ,
485
- watchers : vec ! [ Box :: new( rx_blueprint. clone( ) ) ] ,
486
- activator : task_crdb_node_id_collector,
487
- } ) ;
488
-
489
447
// Background task: inventory collector
490
448
//
491
449
// This depends on the "output" of the blueprint executor in
@@ -515,6 +473,58 @@ impl BackgroundTasksInitializer {
515
473
inventory_watcher
516
474
} ;
517
475
476
+ // Background task: blueprint planner
477
+ //
478
+ // Replans on inventory collection and changes to the current
479
+ // target blueprint.
480
+ let blueprint_planner = blueprint_planner:: BlueprintPlanner :: new (
481
+ datastore. clone ( ) ,
482
+ false ,
483
+ inventory_watcher. clone ( ) ,
484
+ rx_blueprint. clone ( ) ,
485
+ ) ;
486
+ let rx_planner = blueprint_planner. watcher ( ) ;
487
+ driver. register ( TaskDefinition {
488
+ name : "blueprint_planner" ,
489
+ description : "Updates the target blueprint" ,
490
+ period : config. blueprints . period_secs_plan ,
491
+ task_impl : Box :: new ( blueprint_planner) ,
492
+ opctx : opctx. child ( BTreeMap :: new ( ) ) ,
493
+ watchers : vec ! [
494
+ Box :: new( inventory_watcher. clone( ) ) ,
495
+ Box :: new( rx_blueprint. clone( ) ) ,
496
+ ] ,
497
+ activator : task_blueprint_planner,
498
+ } ) ;
499
+
500
+ // The loader watches the planner so that it can immediately load
501
+ // a new target blueprint.
502
+ driver. register ( TaskDefinition {
503
+ name : "blueprint_loader" ,
504
+ description : "Loads the current target blueprint from the DB" ,
505
+ period : config. blueprints . period_secs_load ,
506
+ task_impl : Box :: new ( blueprint_loader) ,
507
+ opctx : opctx. child ( BTreeMap :: new ( ) ) ,
508
+ watchers : vec ! [ Box :: new( rx_planner. clone( ) ) ] ,
509
+ activator : task_blueprint_loader,
510
+ } ) ;
511
+
512
+ // Background task: CockroachDB node ID collector
513
+ let crdb_node_id_collector =
514
+ crdb_node_id_collector:: CockroachNodeIdCollector :: new (
515
+ datastore. clone ( ) ,
516
+ rx_blueprint. clone ( ) ,
517
+ ) ;
518
+ driver. register ( TaskDefinition {
519
+ name : "crdb_node_id_collector" ,
520
+ description : "Collects node IDs of running CockroachDB zones" ,
521
+ period : config. blueprints . period_secs_collect_crdb_node_ids ,
522
+ task_impl : Box :: new ( crdb_node_id_collector) ,
523
+ opctx : opctx. child ( BTreeMap :: new ( ) ) ,
524
+ watchers : vec ! [ Box :: new( rx_blueprint. clone( ) ) ] ,
525
+ activator : task_crdb_node_id_collector,
526
+ } ) ;
527
+
518
528
// Cleans up and collects support bundles.
519
529
//
520
530
// This task is triggered by blueprint execution, since blueprint
0 commit comments