-
Notifications
You must be signed in to change notification settings - Fork 105
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
Integrate with Notifications plugin for Alerting backend #401
Integrate with Notifications plugin for Alerting backend #401
Conversation
.../kotlin/org/opensearch/alerting/util/destinationmigration/DestinationMigrationUtilService.kt
Show resolved
Hide resolved
logger.info("Migrated ${migratedDestinations.size} destinations") | ||
val failedDeletedDestinations = deleteOldDestinations(client, migratedDestinations) | ||
logger.info("Failed to delete ${failedDeletedDestinations.size} destinations from migration process cleanup") | ||
val migratedConfigs = createNotificationChannelIfNotExists(client, configsToMigrate) |
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.
This might be scope of this PR, but what if the user who created the notification config, is deleted? Will it still migrate it? Or will it fail and keep retrying forever?
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.
You mean the user we're trying to inject in the thread context for the object is deleted?
Hmm, Security might handle that and treat it as no permissions? We'll want to test that when we test Alerting/Notif security integration. That's out of scope for this PR for now but a good callout.
.../kotlin/org/opensearch/alerting/util/destinationmigration/DestinationMigrationUtilService.kt
Show resolved
Hide resolved
// Adding a check on TEST_ACTION Destination type here to avoid supporting it as a LegacyBaseMessage type | ||
// just for Alerting integration tests | ||
if (config.destination?.isTestAction() == true) { | ||
return "test action" |
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.
can we define this constant somewhere else and use it both at the time assert and here.
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.
+1
return "test action" | ||
} | ||
|
||
if (config.destination?.isAllowed(allowList) == false) { |
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.
can we rename allowList
to destinationsAllowList
for better readability.
// Adding a check on TEST_ACTION Destination type here to avoid supporting it as a LegacyBaseMessage type | ||
// just for Alerting integration tests | ||
if (config.destination?.isTestAction() == true) { | ||
return "test action" |
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.
+1
@@ -85,6 +96,14 @@ class DestinationSettings { | |||
return concreteSetting.get(settings) | |||
} | |||
|
|||
private fun <T> fallback(key: String, affixSetting: AffixSetting<T>, regex: String, replacement: String): Setting<T>? { | |||
return if ("_na_" == key) { |
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.
same as above
…d Notification Channels Signed-off-by: Mohammad Qureshi <[email protected]>
…to either Notification Channels or Destination Signed-off-by: Mohammad Qureshi <[email protected]>
…TEST_ACTION for tests Signed-off-by: Mohammad Qureshi <[email protected]>
Signed-off-by: Mohammad Qureshi <[email protected]>
Signed-off-by: Mohammad Qureshi <[email protected]>
Signed-off-by: Mohammad Qureshi <[email protected]>
Signed-off-by: Mohammad Qureshi <[email protected]>
Signed-off-by: Mohammad Qureshi <[email protected]>
Signed-off-by: Mohammad Qureshi <[email protected]>
…vice Signed-off-by: Mohammad Qureshi <[email protected]>
76ebd85
to
a997d40
Compare
Codecov Report
@@ Coverage Diff @@
## main #401 +/- ##
============================================
+ Coverage 78.31% 78.50% +0.19%
+ Complexity 268 263 -5
============================================
Files 180 180
Lines 7631 7625 -6
Branches 1065 1069 +4
============================================
+ Hits 5976 5986 +10
+ Misses 1106 1083 -23
- Partials 549 556 +7
Continue to review full report at Codecov.
|
As discussed, the non-blocking comments will be addressed in a follow-up. Also, the only failing GitHub Actions now that the dependent PRs are merged in is the security workflow which is being fixed in #407, merging in for now. |
…project#401) * Add utils for retrieving notifications to both legacy Destinations and Notification Channels Signed-off-by: Mohammad Qureshi <[email protected]> * Refactor runAction in MonitorRunner to be able to send notifications to either Notification Channels or Destination Signed-off-by: Mohammad Qureshi <[email protected]> * Fix error handling when Notification config is not found and support TEST_ACTION for tests Signed-off-by: Mohammad Qureshi <[email protected]> * Fix issue with fallback setting for Destination email keystore settings Signed-off-by: Mohammad Qureshi <[email protected]> * Add publishing email Destinations via Notifications passthrough API Signed-off-by: Mohammad Qureshi <[email protected]> * Remove unused code in NotificationApiUtils Signed-off-by: Mohammad Qureshi <[email protected]> * Use subject as the title for Email Channels Signed-off-by: Mohammad Qureshi <[email protected]> * Combine runAction() methods Signed-off-by: Mohammad Qureshi <[email protected]> * Pass accountName to LegacyEmailMessage Signed-off-by: Mohammad Qureshi <[email protected]> * Split retrieval of Destination configs in DestinationMigrationUtilService Signed-off-by: Mohammad Qureshi <[email protected]> Signed-off-by: Angie Zhang <[email protected]>
Issue #, if available: #105
Description of changes:
This PR depends on opensearch-project/common-utils#158 and opensearch-project/notifications#406 so the GitHub Actions are expected to fail without at least
common-utils
being merged inThe main changes in this PR are:
email_group
configs were being checked with a string match which could also appear in the Email Destination (this would cause it to use the wrong parser so the fetching of the different config types has been split up)opendistro*.
variants this would cause runtime errors when it tried to load the keystore settings and failed on falling back to the old settingCheckList:
[x] Commits are signed per the DCO using --signoff
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.