Repository navigation
refactor(alerts): give alerting code one home - #35032
Conversation
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
…d unused event classes
…t with one job class
c75dff8 to
f557c6f
Compare
🔄 Playwright impact map auto-refreshedThis PR touched specs or UI source that changed the source→spec routing map. I regenerated What is this file? It is the auto-generated half of Playwright's PR planner. It routes "if source X changes, run specs Y" by walking spec imports and cross-referencing What if I want to regenerate locally instead? Run this before pushing your next change to skip the bot commit: python3 .github/scripts/generate_playwright_impact_map.py
git add .github/playwright/impact-map.generated.json
git commit --amend --no-edit # or a separate commit |
| A consumer class can move, be renamed or stop being a Quartz job without a data migration, and | ||
| the API never loads a class a client names. The field keeps the name `className` so the wire shape | ||
| does not change; renaming it is a wire change for a later release. `AbstractEventConsumer` keeps a | ||
| deprecated `execute` that runs `ConsumerJob` until 2.3, so a job that a server of a release before |
There was a problem hiding this comment.
I don't think the deprecated execute helps the default consumer here. It only kicks in if the old class still loads under its old name, but AlertPublisher moved out of apps.bundles.changeEvent, and in AlertConsumers that name is only an alias string. So a job that a 2.0 pod stores under org.openmetadata.service.apps.bundles.changeEvent.AlertPublisher won't load on a 2.1 pod either, and Quartz puts the trigger in ERROR. What actually rescues it is AlertJobView.job() treating the unreadable job as missing so the reconciler re-stores it.
Also, "at most one reconcile round" is per incident. With the helm chart, migrations run in the new pod's init container while the old pod is still up, and a 2.0 pod has no reconciler. Every time it grabs a ConsumerJob trigger it knocks it back into ERROR, so the real bound is however long the rollout takes plus up to one 10 min round. The ledger means nothing gets lost, only delayed, so I'm fine with the behaviour. I'd just word the ADR that way so nobody reads it as a hard bound.
There was a problem hiding this comment.
You're right. The deprecated execute only helps a consumer whose class kept its name, which today means Collate's reverse metadata and credit usage consumers. The default consumer's class moved, so a job a 2.0 pod stores under the old AlertPublisher name never loads on 2.1, and it's the reconciler treating that job as missing that brings it back. The bound is per incident too: the old pod keeps knocking ConsumerJob triggers into error until it stops, so it's the rollout plus one 10 minute round. The ADR now says exactly that in f22e351.
| /** The consumer of an alert that names none: it sends the alert's notifications. */ | ||
| public static final String DEFAULT = "alert"; | ||
|
|
||
| private static final Map<String, ConsumerProvider> REGISTERED = load(); |
There was a problem hiding this comment.
Nothing touches Consumers during startup (AlertConsumers.ID is a compile-time constant, so it gets inlined), so this only loads the first time a tick, a create/PUT or a diagnostics call reaches it. If two providers answer to one name, or a services entry is broken (say a plugin jar that ships a duplicate id), the server comes up fine. The first touch then throws ExceptionInInitializerError, and every tick and request after that gets NoClassDefFoundError until restart, including the default alert consumer. That's not the "stop the server" behaviour the ADR describes.
Could we force the load in EventSubscriptionResource.initialize, next to EventsSubscriptionRegistry.initialize(...) and outside the try, the same way the catalog is handled there?
There was a problem hiding this comment.
Good catch, confirmed: nothing loads it before the first tick, save or diagnostics call, and a duplicate id would then break every alert until a restart. EventSubscriptionResource.initialize now loads the consumers right after the catalog, outside the try, so a duplicate fails once at startup with the name in the log (f22e351). While there I fixed the wording: neither this nor the catalog stops the server, because CollectionRegistry catches what initialize throws and logs it. So the server comes up with alerting off, and the ADR and the comment above that line now say so.
| @@ -0,0 +1,2 @@ | |||
| org.openmetadata.service.alerting.channel.builtin.BuiltInChannels | |||
There was a problem hiding this comment.
Could the release note mention the SPI renames as well? Anyone shipping their own channel or attachment provider has to rename their services file (ChannelProvider and AttachmentProvider both changed package), and if they only fix the imports it still compiles, but ServiceLoader quietly finds nothing and their channels just disappear. Same for a custom consumer: it now needs a ConsumerProvider with its old class name as an alias, otherwise its stored alerts get a 400 on save and the migration leaves them alone. One line in the release note would save someone a confusing afternoon.
There was a problem hiding this comment.
The consumer part is real, so the release note now has a line for it: a plugin consumer needs a ConsumerProvider that lists its old class name as an alias, or its alerts are left unmigrated, their ticks send nothing and saves get a 400. The channel and attachment ones don't need a note. ChannelProvider and AttachmentProvider first ship in 2.1.0 with this PR (they're not on 2.0.5), so no released plugin has a services file under the old names. The only thing built against them in between is Collate, and PR #7259 updates it.
Code Review ✅ Approved 2 closed / 2 findings🔴 High risk · The 2.1.0 migration rewrites stored alert consumer IDs and scheduled jobs; incorrect mappings could prevent alerts from running. Refactors alerting code into two homes: ✅ 2 closed✅ Quality: ServiceDocPanel adds a literal
|
| Compact |
|
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source
|
|
🚦 Removed from the merge queue —
|
Resolves import conflicts in EntityCsv, TaskWorkflowHandler and EntityCsvTest: FormatterUtil moved to events.ChangeEvents (#35032). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>



What this pull request does
Alerting code sat in about 40 packages under 11 roots, and about 20 package pairs imported each other. This pull request gives it two homes and lets the build hold the boundaries:
events.consumeris the runtime every change-event consumer runs on: the tick, the consumer kinds, scheduling and the ledger. It knows nothing of alerting.alertingholds alerts and notifications in layers. Matching is at the bottom, then definition, audience and content, the channel SPI, one package per channel, delivery, and the alert's consumer on top.How to review it
Commit by commit. The first seven commits delete dead code and cut the dependencies that kept the code tangled; each compiles on its own. The eighth commit is the move itself, done by the OpenRewrite recipe committed in
.github/rewrite/alerting-packages.yml. It is rename-only apart from two path strings in guard tests. The commits after it ship the consumer id migration in 2.1.0 and keep its tests passing, merge main, and add the schema descriptions and the decision record.Changes in behaviour (release note)
alertfor alerts) instead of a Java class name. The 2.1.0 migration converts stored alerts and their scheduled jobs. A class name a consumer was stored under is still accepted and saved as its id; an unknown consumer is refused with a 400, as before.ConsumerProviderlisted inMETA-INF/services, with the class name its alerts stored as an alias. Until it is, the migration leaves those alerts as they are, their ticks send nothing (nothing is lost), and saving one is refused with a 400.org.openmetadata.service.events.*andapps.bundles.changeEventmoved toevents.consumerandalerting.typedEvent.jsonandhandlebarsHelpers.jsonmoved Java package; the JSON is unchanged.Boundaries
AlertingArchitectureTestfails the build when:How it was tested
git cherry-pick -X find-renames. It landed in the old paths, built and passed.Fixes #35030