-
Notifications
You must be signed in to change notification settings - Fork 80
Refactor Email Destination #244
Refactor Email Destination #244
Conversation
Codecov Report
@@ Coverage Diff @@
## master #244 +/- ##
============================================
- Coverage 78.61% 75.13% -3.49%
- Complexity 159 191 +32
============================================
Files 91 134 +43
Lines 3273 4403 +1130
Branches 464 581 +117
============================================
+ Hits 2573 3308 +735
- Misses 460 786 +326
- Partials 240 309 +69
Continue to review full report at Codecov.
|
We could find a better way to deal with the "patch" coverage check. |
...ing/src/main/kotlin/com/amazon/opendistroforelasticsearch/alerting/model/MonitorRunResult.kt
Outdated
Show resolved
Hide resolved
...ing/src/main/kotlin/com/amazon/opendistroforelasticsearch/alerting/model/MonitorRunResult.kt
Outdated
Show resolved
Hide resolved
.../main/kotlin/com/amazon/opendistroforelasticsearch/alerting/model/destination/email/Email.kt
Show resolved
Hide resolved
.../main/kotlin/com/amazon/opendistroforelasticsearch/alerting/model/destination/email/Email.kt
Outdated
Show resolved
Hide resolved
...otlin/com/amazon/opendistroforelasticsearch/alerting/model/destination/email/EmailAccount.kt
Outdated
Show resolved
Hide resolved
.../kotlin/com/amazon/opendistroforelasticsearch/alerting/model/destination/email/EmailGroup.kt
Outdated
Show resolved
Hide resolved
alerting/src/main/kotlin/com/amazon/opendistroforelasticsearch/alerting/MonitorRunner.kt
Outdated
Show resolved
Hide resolved
alerting/src/main/kotlin/com/amazon/opendistroforelasticsearch/alerting/MonitorRunner.kt
Outdated
Show resolved
Hide resolved
alerting/src/main/kotlin/com/amazon/opendistroforelasticsearch/alerting/MonitorRunner.kt
Outdated
Show resolved
Hide resolved
...ing/src/main/kotlin/com/amazon/opendistroforelasticsearch/alerting/model/MonitorRunResult.kt
Outdated
Show resolved
Hide resolved
...mazon/opendistroforelasticsearch/alerting/destination/response/DestinationEmailResponse.java
Outdated
Show resolved
Hide resolved
.../main/kotlin/com/amazon/opendistroforelasticsearch/alerting/model/destination/Destination.kt
Outdated
Show resolved
Hide resolved
...otlin/com/amazon/opendistroforelasticsearch/alerting/model/destination/email/EmailAccount.kt
Show resolved
Hide resolved
.../kotlin/com/amazon/opendistroforelasticsearch/alerting/model/destination/email/EmailGroup.kt
Show resolved
Hide resolved
...n/com/amazon/opendistroforelasticsearch/alerting/resthandler/RestDeleteEmailAccountAction.kt
Outdated
Show resolved
Hide resolved
* Support SSL/TLS * Authentification * Message's body is html by dedault
…bout mail destination
- exception handling for mail server username and password - default mail server port is 587
…ent data class and updated Email data class to use new fields
…be 'Email' in class names
When do you think this feature will be released? |
…er to separate classes
…nt/EmailGroup GetRequest
...ain/kotlin/com/amazon/opendistroforelasticsearch/alerting/model/destination/CustomWebhook.kt
Outdated
Show resolved
Hide resolved
...com/amazon/opendistroforelasticsearch/alerting/transport/TransportIndexEmailAccountAction.kt
Show resolved
Hide resolved
Looks like coverage is going down by 3.57%, that seems to more. Is it possible to increase the coverage? |
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.
Mostly just minor comments, everything else looks good to me
...c/main/kotlin/com/amazon/opendistroforelasticsearch/alerting/model/AlertingConfigAccessor.kt
Show resolved
Hide resolved
...om/amazon/opendistroforelasticsearch/alerting/model/destination/DestinationContextFactory.kt
Outdated
Show resolved
Hide resolved
...om/amazon/opendistroforelasticsearch/alerting/model/destination/DestinationContextFactory.kt
Outdated
Show resolved
Hide resolved
...om/amazon/opendistroforelasticsearch/alerting/model/destination/DestinationContextFactory.kt
Outdated
Show resolved
Hide resolved
...otlin/com/amazon/opendistroforelasticsearch/alerting/model/destination/email/EmailAccount.kt
Show resolved
Hide resolved
...om/amazon/opendistroforelasticsearch/alerting/model/destination/DestinationContextFactory.kt
Show resolved
Hide resolved
...om/amazon/opendistroforelasticsearch/alerting/destination/client/DestinationEmailClient.java
Show resolved
Hide resolved
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.
Based on offline discussions we plan to address the coverage reduction in followup PR's.
Great! |
* Add Mail destination * Support SSL/TLS * Authentification * Message's body is html by dedault * Mail destination : move settings to elasticsearch settings * Add loading of mail settings * Remove Dynamic setting property for mail settings. Update README.md about mail destination * Changes from review: - exception handling for mail server username and password - default mail server port is 587 * Make keystore destination settings reloadable * Updated scheduled-jobs mapping * Removed DestinationSettings and DestinationMailSettings, added Recipient data class and updated Email data class to use new fields * Added EmailAccount and EmailGroup data classes * Refactored publishing of Email Destination to use EmailAccount and EmailGroup * Refactored MailMessage and renamed to EmailMessage * Refactored DestinationMailClient and renamed references to 'Mail' to be 'Email' in class names * Added rest handlers for EmailAccount and EmailGroup index and delete actions * Fix style issues * Updated schema version for scheduled jobs index in tests * Fixed existing email destination tests to pass with refactored changes * Added new RestHandlers to AlertingPlugin * Added tests for new components * Added rest handlers for searching and getting EmailAccount and EmailGroup * Fixed parsing error with GET API for EmailAccount and EmailGroup * Moved Email settings from AlertingSettings to DestinationSettings and fixed issue for loading keystore settings * Add license headers to new files * Updated README * Fixed incorrect call to ScheduledJob.parse in search rest handlers for EmailAccount and EmailGroup * Change to use exists query in EmailAccount and EmailGroup search APIs * Make Email model class streamable * Fix tests * Use 'use' scoped function instead of 'let' for Closeable secure settings * Add/update tests * Update UNCHECKED_CAST suppressions to match 'master' branch implementation * Make Email extend Writeable * Combine DestinationHttpResponse and DestinationEmailResponse to DestinationResponse * Move email_accounts and email_groups APIs under 'destinations' namespace * Make EmailAccount and EmailGroup writeable * Add action to DELETE email_account API * Add action to DELETE email_group API * Add action to INDEX/UPDATE email_account API * Add action to INDEX/UPDATE email_group API * Add validation for name when creating/updating email_account * Remove duplicate code from EmailAccount and EmailGroup TransportIndexAction classes * Add action to SEARCH email_account API * Add action to SEARCH email_group API * Add version to EmailAccount * Add version to EmailGroup * Add action to GET email_account API * Add action to GET email_group API * Add rest tests for EmailAccount and EmailGroup * Added validation for name and email in email model classes * Separated calls to get info from alerting confix index in MonitorRunner to separate classes * Fix IllegalStateException warn messages and handle null in EmailAccount/EmailGroup GetRequest * Add JavaMail to third-party libraries list * Fix failing test after resolving merge conflict from master * Add missing return and remove unnecessary comments Co-authored-by: David Chauvière <[email protected]> Co-authored-by: David Chauviere <David Chauviere [email protected]>
Issue #, if available: #3
Description of changes:
This PR is built upon the original one for the Email Destination feature enhancement: #102
The purpose of these changes is to refactor the Email Destination to allow for more flexible use cases and provide ease in scaling out the use of email notifications in Alerting.
Email Accounts
These changes introduce
email_accounts
which are stored in theopendistro-alerting-config
index like other Alerting configurations. This allows for there to be multiple sender emails configured for use in Destinations. A single configuredemail_account
can be used in multiple Destinations and is referred to by itsid
in the Destination configuration so that changing theemail_account
reflects the change in all Destinations that reference it.The Elasticsearch keystore will still be used for storing the username and password for an email when authentication is required. Since there can now be multiple sender emails the stored settings will be namespaced based on the
name
of theemail_account
. For example, if theemail_account
had the name"test_account"
the settings to be added to the keystore would be as follows:Email Groups
This PR also introduces
email_groups
which are similar to mailing lists. Theseemail_groups
can be used to refer to a set group of emails when creating Email Destinations. Similar toemail_accounts
, theseemail_groups
can be used in multiple Destinations. The recipient list for an Email Destination can also be a combination ofemail_groups
and single emails.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.