Skip to content

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:

  1. The alert gets shown after the page got rendered completely, which results into a jumping page
  2. 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

  1. Sign in with root
  2. Go to http://localhost:3000/admin/application_settings/general -> Account and limit
  3. Set Maximum namespace storage (MB) to 20 (or something between 10 - 20)
  4. 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!
  1. Go to http://localhost:3000/twitter for the group overview
  2. Go to http://localhost:3000/twitter/typeahead-js/ for a project

Screenshots

Project Page Group Detail Page Project Page with CI alert
Screenshot_2020-05-25_at_19.35.44 Screenshot_2020-05-25_at_19.40.19 Screenshot_2020-05-25_at_19.41.21

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

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
Edited by Mayra Cabrera

Merge request reports