Modifies storage email notifications to be async
What does this MR do and why?
When testing the email notifications we noticed that the emails were not actually being sent due to not using a delivery method on the mail object.
This MR should address that by using the deliver_now
method.
As per the Rails API docs, without a deliver_*
method, calling the mailer method only returns an ActionMailer::MessageDelivery
object.
Refs https://gitlab.com/gitlab-org/gitlab/-/issues/368493
It's worth noting that the service being modified in this MR is not used in production as it's currently behind a variety of feature flags and application settings as part of the on-going storage work (https://gitlab.com/groups/gitlab-org/-/epics/3472).
How to set up and validate locally
- Lookup the root storage statistics for a namespace:
rss = Namespace::RootStorageStatistics.last namespace = rss.namespace
- Modify the RSS to indicate a low level of notification level:
rss.update(notification_level: 'storage_remaining')
- Modify the
Namespace::RootStorageSize#usage_ratio
method to return 1 (faking that storage limits have been reached) - Trigger the email service
Namespaces::Storage::EmailNotificationService.new(::Emails::NamespaceStorageUsageMailer).execute(namespace)
After it processes, you should see the email in the output.
If you were to attempt this process on master
(i.e. before this change), you would not see the email output.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.