-
Notifications
You must be signed in to change notification settings - Fork 45
Add bg task for collecting chicken switches from DB #8462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Wire up the task watcher into the planner so that it only runs when the `planner_enabled` switch is set to `true. Fixes #8253
Manual testing:
|
ChickenSwitchesCollector::new(datastore.clone()); | ||
let chicken_switches_watcher = chicken_switches_collector.watcher(); | ||
driver.register(TaskDefinition { | ||
name: "chickens_switches_watcher", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name: "chickens_switches_watcher", | |
name: "chicken_switches_watcher", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, just some minor nits 👍
@@ -441,6 +441,8 @@ pub struct BackgroundTaskConfig { | |||
pub webhook_deliverator: WebhookDeliveratorConfig, | |||
/// configuration for SP ereport ingester task | |||
pub sp_ereport_ingester: SpEreportIngesterConfig, | |||
/// reconfigurator runtime configuration | |||
pub chicken_switches: ChickenSwitchesConfig, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nit - should these live under BlueprintTasksConfig
? So in the TOML, it'd be something like
blueprint.chicken_switches.loader_period_secs = N
or if we only expect this to ever really have the period, maybe eliminate the ChickenSwitchesConfig
struct and make it
blueprints.chicken_switches_loader_period_secs = N
|
||
impl Default for ChickenSwitchesConfig { | ||
fn default() -> Self { | ||
Self { period_secs: Duration::from_secs(5) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need a default? (If yes, why is it 5 here but 30 in the config files?)
@@ -48,6 +48,7 @@ pub struct BackgroundTasks { | |||
pub task_alert_dispatcher: Activator, | |||
pub task_webhook_deliverator: Activator, | |||
pub task_sp_ereport_ingester: Activator, | |||
pub task_chicken_switches_collector: Activator, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tiny nit - maybe
pub task_chicken_switches_collector: Activator, | |
pub task_chicken_switches_loader: Activator, |
I'm not sure we've been consistent with this, but I'd expect "_collector" to be a task that goes out and collects things (e.g., inventory), vs "_loader" is a task that reads stuff from the DB.
@@ -24,7 +25,7 @@ use tokio::sync::watch::{self, Receiver, Sender}; | |||
/// Background task that runs the update planner. | |||
pub struct BlueprintPlanner { | |||
datastore: Arc<DataStore>, | |||
disabled: bool, | |||
rx_chicken_switches: Receiver<Option<ReconfiguratorChickenSwitches>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand why this is an Option
, but does it need to be? Presumably for every possible chicken switch, we have some default value (i.e., the thing we'd choose if this is None
). Could we populate the channel with a ReconfiguratorChickenSwitches
with those values set to avoid having to deal with None
at all in this task?
Oh, as I write that I guess we don't have a default for version
. How gross would it be to fill in a version: 0
for this "made up default" set of switches?
Wire up the task watcher into the planner so that it only runs when the
planner_enabled
switch is set to `true.Fixes #8253