Updates the copy of email alerts for namespace storage limits
What does this MR do and why?
Updates emails (subject and body), sent for namespace storage size limits warning (70%+) and overage (100%+).
Resolves https://gitlab.com/gitlab-org/gitlab/-/issues/383393
Screenshots or screen recordings
Warning level (70%+)
Subject:
You have used 95% of the storage quota for H5bp
HTML
You have used 95% of the storage quota for H5bp (24.8 MB of 26 MB).
If H5bp exceeds the storage quota, all projects in the namespace will be locked and actions will be restricted. Which actions become restricted?
Manage your storage usage or purchase additional storage. Learn more.
Text copy
You have used 95% of the storage quota for H5bp (24.8 MB of 26 MB). See storage usage statistics: http://127.0.0.1:3000/groups/h5bp/-/usage_quotas#storage-quota-tab
If H5bp exceeds the storage quota, all projects in the namespace will be locked and actions will be restricted. Learn about which actions become restricted: http://127.0.0.1:3000/help/user/read_only_namespaces http://127.0.0.1:3000/help/user/read_only_namespaces
Manage your storage usage or purchase additional storage. Learn more: http://127.0.0.1:3000/help/user/usage_quotas#manage-your-storage-usage
Buy more storage → http://127.0.0.1:3000/-/subscriptions/buy_storage?selected_group=35
Over the limit (100%+)
Subject:
Action required: Storage has been exceeded for H5bp
HTML
You have used 142% of the storage quota for H5bp (30 MB of 21 MB).
H5bp is now read-only. Projects under this namespace are locked and actions are restricted. Which actions are restricted?
Manage your storage usage or purchase additional storage. Learn more.
Text
You have used 142% of the storage quota for H5bp (30 MB of 21 MB). See storage usage statistics: http://127.0.0.1:3000/groups/h5bp/-/usage_quotas#storage-quota-tab
H5bp is now read-only. Projects under this namespace are locked and actions are restricted. Learn about which actions are restricted: http://127.0.0.1:3000/help/user/read_only_namespaces http://127.0.0.1:3000/help/user/read_only_namespaces
Manage your storage usage or purchase additional storage. Learn more: http://127.0.0.1:3000/help/user/usage_quotas#manage-your-storage-usage
Buy more storage → http://127.0.0.1:3000/-/subscriptions/buy_storage?selected_group=35
How to set up and validate locally
First, we'll need to patch some code that guards duplicate emails and triggers immediate delivery:
diff --git a/ee/app/services/namespaces/storage/email_notification_service.rb b/ee/app/services/namespaces/storage/email_notification_service.rb
index b9a4034a7965..6f147684b15b 100644
--- a/ee/app/services/namespaces/storage/email_notification_service.rb
+++ b/ee/app/services/namespaces/storage/email_notification_service.rb
@@ -14,10 +14,10 @@ def execute(namespace)
level = notification_level(root_storage_size)
last_level = namespace.root_storage_statistics.notification_level.to_sym
- if level != last_level
+ # if level != last_level
send_notification(level, namespace, root_storage_size)
- update_notification_level(level, namespace)
- end
+ # update_notification_level(level, namespace)
+ # end
end
private
@@ -35,7 +35,7 @@ def notification_level(root_storage_size)
end
def send_notification(level, namespace, root_storage_size)
- return if level == :storage_remaining
+ # return if level == :storage_remaining
owner_emails = namespace.owners.map(&:email)
usage_values = {
@@ -48,12 +48,12 @@ def send_notification(level, namespace, root_storage_size)
mailer.notify_out_of_storage(
namespace: namespace,
recipients: owner_emails,
- usage_values: usage_values).deliver_later
+ usage_values: usage_values).deliver_now
else
mailer.notify_limit_warning(
namespace: namespace,
recipients: owner_emails,
- usage_values: usage_values).deliver_later
+ usage_values: usage_values).deliver_now
end
end
Then we'll need to update namespace limits to fit our needs. 20
is a limit in MiB, you'll need to be 70%+ for warning emails, and 100%+ for errors:
free_plan = Plan.find_by_name "free"
free_plan_limit = free_plan.limits
free_plan_limit.update(storage_size_limit: 20)
free_plan_limit.save
free_plan.save
default_plan = Plan.find_by_name "default"
default_plan_limit = default_plan.limits
default_plan_limit.update(storage_size_limit: 20)
default_plan_limit.save
default_plan.save
There are some caches involved, better do gdk restart
here
Then we need to pick a group and use it for sending emails.
# rails c
group = Group.find(35)
mailer = ::Emails::NamespaceStorageUsageMailer
::Namespaces::Storage::EmailNotificationService.new(mailer).execute(group)
After that — you can open http://127.0.0.1:3000/rails/letter_opener to see sent emails.
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.