Show a combined banner when exceeding both storage and user limits
What does this MR do and why?
This MR closes: https://gitlab.com/gitlab-org/gitlab/-/issues/383578
In this MR/Issue:
We are creating a combined alert for free tier namespaces exceeding both storage and user limits.
Q/A:
-
Alert access level?
- This alert shows to owners and non-owners
-
Dismisable?
- Yes, every 14 days
-
Are we dismissing the other 2 standalone banners for user/storage alerts when showing this one?
- Yes, this combined banner applies only in pre-enforcement, if it's rendered we don't render the storage banner, and namespaces in users' limit enforcement are excluded (returns
false
), more details could be found here: https://gitlab.com/gitlab-org/gitlab/-/issues/409414#note_1384263672
- Yes, this combined banner applies only in pre-enforcement, if it's rendered we don't render the storage banner, and namespaces in users' limit enforcement are excluded (returns
-
Is it a featured flagged?
- Yes, both user cap and storage limits are feature flagged
-
CTAs?
- Yes, only to owners.
Screenshots or screen recordings
Owner
Non-owner
How to set up and validate locally
To validate this locally, you should be exceeding both storage and user limits.
-
Easy way? You can return
true
for exceeding both storage/user limits.- Storage-> ::Namespaces::Storage::Enforcement.reached_pre_enforcement_notification_limit?(namespace) # override to return true
- Users-> ::Namespaces::FreeUserCap::EnforcementWithoutStorage.new(namespace).reached_limit? # override to return true
A detailed guide for exceeding both storage and user limits:
Exceeding storage limits:
bin/rails c
# Enable feature flag:
::Feature.enable(:namespace_storage_limit_show_preenforcement_banner)
# ensuring we're not enforcing limits, which shows a different banner:
::Gitlab::CurrentSettings.update(enforce_namespace_storage_limit: false)
# Get a testing group
testing_group = Group.find(Group_ID)
# set a notification limit (I adjusted this to test different scenarios over/below/0):
testing_group.actual_limits.update(notification_limit: 100)
# setup testing_group to have a storage size greater than my notification limit
testing_group.root_storage_statistics.update(storage_size: 1024.megabytes) # or override `current_size` in `ee/app/models/namespaces/storage/root_size.rb`
Exceeding user limits:
bin/rails c
ApplicationSetting.first.update(dashboard_limit_enabled: false)
Feature.disable(:free_user_cap)
Feature.disable(:free_user_cap_new_namespaces)
- Sign in as a free user. Create public groups and private projects inside.
- Add 4+ members.
bin/rails c
ApplicationSetting.first.update(dashboard_limit_enabled: true, dashboard_limit: 3)
Feature.enable(:free_user_cap)
Feature.enable(:free_user_cap_new_namespaces)
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.
Edited by Doug Stull