Skip to content

Commit cf5c7f3

Browse files
fix(scaler): react to config set events for components/providers
Signed-off-by: Brooks Townsend <[email protected]>
1 parent 1926bf0 commit cf5c7f3

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

crates/wadm/src/scaler/daemonscaler/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use tokio::sync::RwLock;
77
use tracing::{instrument, trace};
88
use wadm_types::{api::StatusInfo, Spread, SpreadScalerProperty, TraitProperty};
99

10+
use crate::events::ConfigSet;
1011
use crate::scaler::spreadscaler::{
1112
compute_ineligible_hosts, eligible_hosts, spreadscaler_annotations,
1213
};
@@ -119,6 +120,9 @@ impl<S: ReadStore + Send + Sync + Clone> Scaler for ComponentDaemonScaler<S> {
119120
Ok(Vec::new())
120121
}
121122
}
123+
Event::ConfigSet(ConfigSet { config_name }) if self.config.contains(config_name) => {
124+
self.reconcile().await
125+
}
122126
// No other event impacts the job of this scaler so we can ignore it
123127
_ => Ok(Vec::new()),
124128
}

crates/wadm/src/scaler/daemonscaler/provider.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use wadm_types::{api::StatusInfo, Spread, SpreadScalerProperty, TraitProperty};
99

1010
use crate::commands::StopProvider;
1111
use crate::events::{
12-
HostHeartbeat, ProviderHealthCheckFailed, ProviderHealthCheckInfo, ProviderHealthCheckPassed,
13-
ProviderInfo, ProviderStarted, ProviderStopped,
12+
ConfigSet, HostHeartbeat, ProviderHealthCheckFailed, ProviderHealthCheckInfo,
13+
ProviderHealthCheckPassed, ProviderInfo, ProviderStarted, ProviderStopped,
1414
};
1515
use crate::scaler::compute_id_sha256;
1616
use crate::scaler::spreadscaler::{
@@ -156,6 +156,11 @@ impl<S: ReadStore + Send + Sync + Clone> Scaler for ProviderDaemonScaler<S> {
156156
// only status needs update no new commands required
157157
Ok(Vec::new())
158158
}
159+
Event::ConfigSet(ConfigSet { config_name })
160+
if self.config.provider_config.contains(config_name) =>
161+
{
162+
self.reconcile().await
163+
}
159164
// No other event impacts the job of this scaler so we can ignore it
160165
_ => Ok(Vec::new()),
161166
}

crates/wadm/src/scaler/spreadscaler/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use wadm_types::{
1010
api::StatusInfo, Spread, SpreadScalerProperty, TraitProperty, DEFAULT_SPREAD_WEIGHT,
1111
};
1212

13-
use crate::events::HostHeartbeat;
13+
use crate::events::{ConfigSet, HostHeartbeat};
1414
use crate::{
1515
commands::{Command, ScaleComponent},
1616
events::{Event, HostStarted, HostStopped},
@@ -114,6 +114,9 @@ impl<S: ReadStore + Send + Sync + Clone> Scaler for ComponentSpreadScaler<S> {
114114
Ok(Vec::new())
115115
}
116116
}
117+
Event::ConfigSet(ConfigSet { config_name }) if self.config.contains(config_name) => {
118+
self.reconcile().await
119+
}
117120
// No other event impacts the job of this scaler so we can ignore it
118121
_ => Ok(Vec::new()),
119122
}

crates/wadm/src/scaler/spreadscaler/provider.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use wadm_types::{
1515
use crate::{
1616
commands::{Command, StartProvider, StopProvider},
1717
events::{
18-
Event, HostHeartbeat, HostStarted, HostStopped, ProviderHealthCheckFailed,
18+
ConfigSet, Event, HostHeartbeat, HostStarted, HostStopped, ProviderHealthCheckFailed,
1919
ProviderHealthCheckInfo, ProviderHealthCheckPassed, ProviderInfo, ProviderStarted,
2020
ProviderStopped,
2121
},
@@ -173,6 +173,11 @@ impl<S: ReadStore + Send + Sync + Clone> Scaler for ProviderSpreadScaler<S> {
173173
// only status needs update no new commands required
174174
Ok(Vec::new())
175175
}
176+
Event::ConfigSet(ConfigSet { config_name })
177+
if self.config.provider_config.contains(config_name) =>
178+
{
179+
self.reconcile().await
180+
}
176181
// No other event impacts the job of this scaler so we can ignore it
177182
_ => Ok(Vec::new()),
178183
}

0 commit comments

Comments
 (0)