-
Notifications
You must be signed in to change notification settings - Fork 669
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
Introduced SMTP notification #5535
Introduced SMTP notification #5535
Conversation
Introduced SMTP notification for Flyte Signed-off-by: Rob Ulbrich <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5535 +/- ##
==========================================
+ Coverage 36.21% 36.25% +0.03%
==========================================
Files 1303 1305 +2
Lines 109644 109874 +230
==========================================
+ Hits 39710 39831 +121
- Misses 65810 65894 +84
- Partials 4124 4149 +25
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Signed-off-by: Rob Ulbrich <[email protected]>
I am sorry about the bad unit test coverage for the |
Signed-off-by: Rob Ulbrich <[email protected]>
Signed-off-by: Rob Ulbrich <[email protected]>
Signed-off-by: Rob Ulbrich <[email protected]>
Signed-off-by: Rob Ulbrich <[email protected]>
# Conflicts: # flyteadmin/go.mod
# Conflicts: # flyteadmin/pkg/server/service.go
Signed-off-by: Ulbrich Robert <[email protected]>
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.
Just a couple questions. Would you mind please also making sure that the new settings are reachable using the flyte-core Helm chart? An example would be lovely. If not could you add to the chart in this PR, or cut another issue so we don't lose track of it?
Thank you!
|
||
func (s *SMTPEmailer) SendEmail(ctx context.Context, email admin.EmailMessage) error { | ||
|
||
newClient, err := smtp.Dial(s.config.EmailerConfig.SMTPServer + ":" + s.config.EmailerConfig.SMTPPort) |
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.
Just to confirm, this is the intended behavior? If admin needs to send a thousand emails, it has to make a new client each time?
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.
Yes, this is intended behavior. When using the built-in email client of Go, most examples you find work that way. Also with the integration into the Notifications processor this is the simplest approach. Establishing a connection does not seem to be a very complex undertaking when looking at the source code of the email client.
I agree that keeping the connection is more efficient. But it also makes the code more complex, because the connection state needs to be maintained over an instance - so whenever an email is meant to be sent, it first needs to be checked if the connection is still alive.
If you want me to, I can refactor it to only open a connection once to the SMTP server.
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.
I just checked again the internal implementation of Golang's smtp client: It appears that the client implementation seems to be not multi-thread-safe. Every client instance keeps an internal state between function calls - so when reusing the same client while sending an email for writing another mail can lead to weird behavior.
My assumption is that there is only a single email processor per Flyte Admin instance. That means that there should be no concurrent email processing on any Flyte Admin instance, which makes it safe to reuse an existing Flyste client.
The settings can already be set with the current Helm chart. Actually the notification settings with Sendgrid and AWS SES also do not have a good support in the Helm charts yet. Well I guess I did not made it better either, but also did not want to fully update the Helm chart here. The settings can be put into; if you want me to update the whole Helm file here, I can do it, but I guess we will then soon lose the scope of the merge request. |
Signed-off-by: Ulbrich Robert <[email protected]>
Signed-off-by: Ulbrich Robert <[email protected]>
Signed-off-by: Ulbrich Robert <[email protected]>
apologies for the delay @robert-ulbrich-mercedes-benz - mind taking a look at the errors in ci here? |
Hi @wild-endeavor, this PR is becoming a never ending story: After I thought that I finally fixed all linting issues - while I could not run the linter locally , since it always broke down - I tried to run it in different docker container with different Golang versions - it never works. When running the linter in the CI, it complains about issues in files that I did not touch. I have no idea how I will ever be able to get a successful build. It is simply annoying. That way new committers are actively kept away :( |
Signed-off-by: Ulbrich Robert <[email protected]>
Also now there are suddenly compilation issues in file |
@robert-ulbrich-mercedes-benz , sorry for the churn. Can you merge master? I was able to repro the CI errors locally after I did that. |
I already merged master into the feature branch - I am up to date with master. |
In a separate environment (like a temp directory), if you setup the repo like so you can repro this locally also:
This is essentially what the actions/checkout@v4 gh action does, e.g.: https://github.com/flyteorg/flyte/actions/runs/10792407625/job/29938153742?pr=5535#step:2:62 |
The emailer interface changed a few days ago (in https://github.com/flyteorg/flyte/blame/master/flyteadmin/pkg/async/notifications/interfaces/emailer.go#L12C4-L12C4), after the last time you merged master. |
Introduced SMTP notification for Flyte Signed-off-by: Rob Ulbrich <[email protected]>
Signed-off-by: Rob Ulbrich <[email protected]>
Signed-off-by: Rob Ulbrich <[email protected]>
Signed-off-by: Rob Ulbrich <[email protected]>
Signed-off-by: Rob Ulbrich <[email protected]>
Signed-off-by: Rob Ulbrich <[email protected]>
Signed-off-by: Ulbrich Robert <[email protected]>
Signed-off-by: Ulbrich Robert <[email protected]>
Signed-off-by: Ulbrich Robert <[email protected]>
Signed-off-by: Ulbrich Robert <[email protected]>
Signed-off-by: Ulbrich Robert <[email protected]>
Signed-off-by: Ulbrich Robert <[email protected]>
Hi @eapolinario, thanks for the hint! Actually Github was playing a trick on me: Yesterday it showed me that I am synced with the |
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.
Docs changes look good to me, but I'll let others approve the rest of the changes.
Signed-off-by: Ulbrich Robert <[email protected]>
helm test should be getting patched soon. |
Signed-off-by: Ulbrich Robert <[email protected]>
Signed-off-by: Ulbrich Robert <[email protected]>
Signed-off-by: Ulbrich Robert <[email protected]>
Signed-off-by: Ulbrich Robert <[email protected]>
Congrats on merging your first pull request! 🎉 |
Why are the changes needed?
Currently E-Mail notifications can only be sent using either SendGrid or SES. In many enterprises none of the both services is used, but there is a custom SMTP server available in the company.
What changes were proposed in this pull request?
A new implementation of the
Emailer
intereface was added. It allows for notifications to be sent via a plain SMTP server. That SMTP server can be configured including authorization.How was this patch tested?
There are automated unit tests. Also the changes were tested against SMTP interface of SES running a one-binary dev environment. The program was tested solely for our own use cases, which might differ from yours.
Setup process
flytectl demo start --dev
flyte-single-binary-local.yaml
as found belowsmtp_ses_password
in/etc/secrets
containing the SES password.make compile
POD_NAMESPACE=flyte ./flyte start --config flyte-single-binary-local.yaml
for workflow:
Screenshots
Check all the applicable boxes
Related PRs
Docs link
Robert Ulbrich[email protected], Mercedes-Benz Tech Innovation GmbH
https://github.com/mercedes-benz/foss/blob/master/PROVIDER_INFORMATION.md