Show alert for namespace storage limit
What does this MR do?
Related to https://gitlab.com/gitlab-org/gitlab/-/issues/211859
It shows an alert for the namespace storage usage on the project and group page of a namespace. This will only be shown to admins of a namespace. We show alerts at 50%, 75%, 95% and 100% usage. These alerts are dismissible for each user/namespace/alert level. We're using a cookie for now to store that dismiss message. This is a temporary solution since we want to convert to a better solution where we keep the hidden state for each user consistently.
It uses the CheckStorageSizeService
which returns all needed information for the alert for the root namespace.
Note: I was explicitly not using the VueAlert
component because it has two downsides:
- The alert gets shown after the page got rendered completely, which results into a jumping page
- While these alerts are dismissible, there is no way to attach an event with data to use it to set the cookie
No changelog because it's behind a feature flag namespace_storage_limit
https://gitlab.com/gitlab-org/gitlab/blob/nicolasdular/namespace-storage-limit-banner/app/services/namespaces/check_storage_size_service.rb#L16
How to prepare locally
- Sign in with
root
- Go to http://localhost:3000/admin/application_settings/general -> Account and limit
- Set Maximum namespace storage (MB) to 20 (or something between 10 - 20)
- Execute the following script:
Feature.enable(:namespace_storage_limit)
n = Group.find_by(name: "Twitter")
n.root_storage_statistics&.destroy!
s = Namespace::RootStorageStatistics.new(
namespace: n,
build_artifacts_size: 400000,
wiki_size: 300000,
repository_size: 3900000,
packages_size: 3800000,
lfs_objects_size: 4800000
)
s.storage_size = s.repository_size + s.lfs_objects_size + s.wiki_size + s.build_artifacts_size + s.packages_size
s.save!
- Go to http://localhost:3000/twitter for the group overview
- Go to http://localhost:3000/twitter/typeahead-js/ for a project
Screenshots
Project Page | Group Detail Page | Project Page with CI alert |
---|---|---|
Does this MR meet the acceptance criteria?
Conformity
- [-] Changelog entry
- [-] Documentation (if required)
-
Code review guidelines -
Merge request performance guidelines -
Style guides - [-] Database guides
-
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers - [-] Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
- [-] Label as security and @ mention
@gitlab-com/gl-security/appsec
- [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
- [-] Security reports checked/validated by a reviewer from the AppSec team