Skip to content

Commit a016336

Browse files
authored
[external API] alerts: the renamening (#8169)
In conversation with @ahl, we have determined that the external API for webhooks added in #7277 should be changed to focus on "alerts" as the first-class user-facing concept, with "webhooks" as one delivery mechanism for alerts. This way, we can talk about alerts as an entity in the API that exist independently of webhooks that deliver alerts, and the same alert types can be shared with other alert delivery mechanisms if any are added in the future. What we currently refer to as "webhook events" and "webhook event classes" are therefore renamed to "alerts" and "alert classes". The current concept of "webhook receivers" is generalized to an "alert receiver" resource, of which webhook receivers are (currently) the only subtype. This way, if we add other mechanisms of delivering alerts in the future (email, first-class Slack integration, etc), we can introduce new subtypes of alert receivers. I've restructured the API to have both `/v1/alert-receivers/...` and `/v1/webhook-receivers/...` routes, with operations common to all alert receivers (list, view, add/remove subscriptions, delete) under the `alert-receivers` route, and operations related to webhook-specific configuration (add/remove secrets, probe, deliveries) under the `webhook-receivers` route. I've also changed the `AlertReceiver` view to have a "kind" enum that stores the subtype-specific configuration; currently, this will only ever be "webhook", but I thought it was worth doing this now to make future additions cause less breakage for API consumers. This is, admittedly, a somewhat large diff, but fortunately, most of it is just renaming stuff and moving it around. Reviewers can focus more or less exclusively to the changes to the external API routes and models, and maybe the database migrations. Any mistakes while renaming and moving things around have already been caught by the Rust compiler. :)
1 parent 2dfd0f1 commit a016336

File tree

91 files changed

+7906
-7359
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+7906
-7359
lines changed

common/src/api/external/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,8 @@ pub enum ResourceType {
977977
AffinityGroupMember,
978978
AntiAffinityGroup,
979979
AntiAffinityGroupMember,
980+
Alert,
981+
AlertReceiver,
980982
AllowList,
981983
BackgroundTask,
982984
BgpConfig,
@@ -1040,8 +1042,6 @@ pub enum ResourceType {
10401042
Probe,
10411043
ProbeNetworkInterface,
10421044
LldpLinkConfig,
1043-
WebhookEvent,
1044-
WebhookReceiver,
10451045
WebhookSecret,
10461046
}
10471047

dev-tools/omdb/src/bin/omdb/db.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use crate::helpers::CONNECTION_OPTIONS_HEADING;
2323
use crate::helpers::DATABASE_OPTIONS_HEADING;
2424
use crate::helpers::const_max_len;
2525
use crate::helpers::display_option_blank;
26+
use alert::AlertArgs;
2627
use anyhow::Context;
2728
use anyhow::anyhow;
2829
use anyhow::bail;
@@ -169,11 +170,9 @@ use std::sync::Arc;
169170
use strum::IntoEnumIterator;
170171
use tabled::Tabled;
171172
use uuid::Uuid;
172-
use webhook::WebhookArgs;
173-
use webhook::cmd_db_webhook;
174173

174+
mod alert;
175175
mod saga;
176-
mod webhook;
177176

178177
const NO_ACTIVE_PROPOLIS_MSG: &str = "<no active Propolis>";
179178
const NOT_ON_SLED_MSG: &str = "<not on any sled>";
@@ -387,8 +386,8 @@ enum DbCommands {
387386
Vmms(VmmListArgs),
388387
/// Print information about the oximeter collector.
389388
Oximeter(OximeterArgs),
390-
/// Print information about webhooks
391-
Webhook(WebhookArgs),
389+
/// Print information about alerts
390+
Alert(AlertArgs),
392391
/// Commands for querying and interacting with pools
393392
Zpool(ZpoolArgs),
394393
}
@@ -1467,7 +1466,7 @@ impl DbArgs {
14671466
command: OximeterCommands::ListProducers
14681467
}) => cmd_db_oximeter_list_producers(&datastore, fetch_opts).await,
14691468

1470-
DbCommands::Webhook(args) => cmd_db_webhook(&opctx, &datastore, &fetch_opts, &args).await,
1469+
DbCommands::Alert(args) => alert::cmd_db_alert(&opctx, &datastore, &fetch_opts, &args).await,
14711470
DbCommands::Zpool(ZpoolArgs {
14721471
command: ZpoolCommands::List(args)
14731472
}) => cmd_db_zpool_list(&opctx, &datastore, &args).await,

0 commit comments

Comments
 (0)