Open
Conversation
Implements [DA231](https://docs.google.com/document/d/1LaMAF5_vuRhcmqam2LbUnOeq-Gy2Le7fKc3lXHJXGmY/edit?tab=t.0) Fixes #777. ## Solution: This PR adds SMTP notifications lifecycle in the OpenSearch charm. The SMTP-related notification configs are created automatically by Opensearch when the smtp-integrator relation is established. - SMTP sender (smtp_account) - Email group (email_group) - Email channel (email) ## How it works Integrate Opensearch with smtp-integrator Configure the SMTP integrator with SMTP credentials: ```shell juju config smtp-integrator \ host="<smtp-host>" \ port="587" \ user="<smtp-username>" \ password="<smtp-password>" \ smtp-sender="<sender-email>" \ recipients="a@example.com,b@example.com" ``` The smtp-sender, email-group and email-channel is automatically created. The config-id is derived from relation-id. ``` sudo curl --cacert /var/snap/opensearch/98/etc/opensearch/certificates/chain.pem -u "admin:${ADMIN_PASSWORD}" "https://10.127.127.111:9200/_plugins/_notifications/configs/" | jq . { "start_index": 0, "total_hits": 3, "total_hit_relation": "eq", "config_list": [ { "config_id": "smtp-85", "last_updated_time_ms": 1769774765184, "created_time_ms": 1769774765184, "config": { "name": "smtp-85", "description": "SMTP sender: (smtp-85)", "config_type": "smtp_account", "is_enabled": true, "smtp_account": { "host": "smtp.gmail.com", "port": 587, "method": "start_tls", "from_address": "h68805701@gmail.com" } } }, { "config_id": "smtp-85_recipients", "last_updated_time_ms": 1769774767882, "created_time_ms": 1769774767882, "config": { "name": "smtp-85_recipients", "description": "Email group managed by (smtp-85_recipients)", "config_type": "email_group", "is_enabled": true, "email_group": { "recipient_list": [ { "recipient": "gulsumatici@gmail.com" } ] } } }, { "config_id": "smtp-85_email-channel", "last_updated_time_ms": 1769774768149, "created_time_ms": 1769774768149, "config": { "name": "smtp-85_email-channel", "description": "Email channel: (smtp-85_email-channel)", "config_type": "email", "is_enabled": true, "email": { "email_account_id": "smtp-85", "recipient_list": [], "email_group_id_list": [ "smtp-85_recipients" ] } } } ] } ``` <img width="1073" height="236" alt="image" src="https://github.com/user-attachments/assets/24a45fb1-41ce-48b5-aff9-46c2060fda71" /> ``` ADMIN_PASSWORD="xxxxx" OS_IP="10.127.127.128" CFG_ID="smtp-85_email-channel" sudo curl --cacert /var/snap/opensearch/current/etc/opensearch/certificates/chain.pem \ -u "admin:${ADMIN_PASSWORD}" \ -X POST "https://${OS_IP}:9200/_plugins/_notifications/feature/test/${CFG_ID}" \ -H "Content-Type: application/json" \ -d '{"subject":"SMTP integration test","message":"Sent via smtp-integrator + OpenSearch"}' {"event_source":{"title":"Test Message Title-smtp-85_email-channel","reference_id":"smtp-85_email-channel","severity":"info","tags":[]},"status_list":[{"config_id":"smtp-85","config_type":"email","config_name":"smtp-85_email-channel","email_recipient_status":[{"recipient":"gulsum.atici@canonical.com","delivery_status":{"status_code":"200","status_text":"Success"}}],"delivery_status":{"status_code":"200","status_text":"Success"}}]} ``` <img width="927" height="403" alt="image" src="https://github.com/user-attachments/assets/36a72470-7b24-416c-9c43-85e236c8376f" /> ## How was this change tested? - [x] Manually - [x] Unit tests - [x] Integration tests <!--- Please describe in detail how you tested your changes. --> <!--- Include details of your testing environment, and the tests you ran to --> <!--- see how your change affects other areas of the code, etc. --> ## Checklist - [ ] I have added or updated any relevant documentation. - [ ] I have cleaned any remaining cloud resources from my accounts. --------- Signed-off-by: gatici <gulsum.atici@canonical.com> Co-authored-by: Mehdi-Bendriss <45567724+Mehdi-Bendriss@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of issue or feature:
Solution:
How was this change tested?
Checklist