Skip to content

Commit 39d85b4

Browse files
skip loading anomaly or forecast alerts
1 parent 4cc0f7a commit 39d85b4

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

src/alerts/mod.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,11 @@ async fn migrate_v1_alert(
150150
}
151151
}
152152

153-
fn alert_from_config_oss(alert: AlertConfig) -> anyhow::Result<Box<dyn AlertTrait>> {
153+
fn alert_from_config_oss(alert: AlertConfig) -> Result<Box<dyn AlertTrait>, AlertError> {
154154
match &alert.alert_type {
155155
AlertType::Threshold => Ok(Box::new(ThresholdAlert::from(alert)) as Box<dyn AlertTrait>),
156-
AlertType::Anomaly(_) => Err(anyhow::Error::msg(
157-
AlertError::NotPresentInOSS("anomaly").to_string(),
158-
)),
159-
AlertType::Forecast(_) => Err(anyhow::Error::msg(
160-
AlertError::NotPresentInOSS("forecast").to_string(),
161-
)),
156+
AlertType::Anomaly(_) => Err(AlertError::NotPresentInOSS("anomaly")),
157+
AlertType::Forecast(_) => Err(AlertError::NotPresentInOSS("forecast")),
162158
}
163159
}
164160

@@ -1173,7 +1169,14 @@ impl AlertManagerTrait for Alerts {
11731169
// ensure that alert config's tenant is correctly set
11741170
alert.tenant_id.clone_from(tenant);
11751171

1176-
let alert = alert_from_config_oss(alert)?;
1172+
let alert = match alert_from_config_oss(alert) {
1173+
Ok(alert) => alert,
1174+
Err(e @ AlertError::NotPresentInOSS(_)) => {
1175+
warn!("Skipping unsupported OSS alert: {e}");
1176+
continue;
1177+
}
1178+
Err(e) => return Err(anyhow::Error::msg(e.to_string())),
1179+
};
11771180

11781181
// Create alert task iff alert's state is not paused
11791182
if alert.get_state().eq(&AlertState::Disabled) {

0 commit comments

Comments
 (0)