Skip to content

Updates copy for namespace storage enforcement locking banner

What does this MR do and why?

It updates the banner text for namespace storage limits when a namespace is close to or is over the limit.

Implements https://gitlab.com/gitlab-org/gitlab/-/issues/371970+

I'm sharing screenshots of both Namespace (updated) and Repository (should be intact) below, since we have logic for Namespace and Repository type enforcement notifications in the same file (notificaiton.rb).

Screenshots or screen recordings

Namespace enforcement type alerts (updated copy)

under limit over limit
localhost_3000_h5bp_html5-boilerplate_-_usage_quotas localhost_3000_h5bp_html5-boilerplate_-usage_quotas__1

Repository enforcement type alerts (unchanged)

under limit over limit
Screenshot_2022-12-14_at_19.09.01 127.0.0.1_3000_groups_project-over-limit_-_usage_quotas

On-push messaging (namespace enforcement message updated)

repo warning (faked via patch) namespace warning
Screenshot_2022-12-12_at_19.46.04 Screenshot_2022-12-12_at_19.43.05

How to set up and validate locally

To reproduce these scenarios you'll need an instance simulating SaaS.

NOTE: if Rails.cache.clear doesn't work — you might restart redis server w/ gdk restart redis. If you still don't see desired notifications — you might need to run group.root_storage_statistics.recalculate! in Rails console. Or restart your gdk.

To reproduce namespace notifications:

rails c

# ---- RAILS CONSOLE: ----

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

group = Group.find(<group_id>)

::Gitlab::CurrentSettings.update(automatic_purchased_storage_allocation: true)
::Gitlab::CurrentSettings.update(check_namespace_plan: true)
::Gitlab::CurrentSettings.update(enforce_namespace_storage_limit: true)
Feature.enable(:namespace_storage_limit, group)
Feature.enable(:enforce_storage_limit_for_paid, group)
Feature.enable(:enforce_storage_limit_for_free, group)

Rails.cache.clear

To simulate namespace storage size you can either tweak the plan.update(storage_size_limit: 20) or actually uploaded files to the repo under that namespace.

A dd if=/dev/urandom of=file.dat bs=1M count=1 would generate a 1 megabyte file on macos.

To reproduce repository notifications
rails c

# ---- RAILS CONSOLE: ----

group = Group.find(<group_id>)

::Gitlab::CurrentSettings.update(automatic_purchased_storage_allocation: true)
::Gitlab::CurrentSettings.update(repository_size_limit: 10.megabytes)
::Gitlab::CurrentSettings.update(check_namespace_plan: true)

::Gitlab::CurrentSettings.update(enforce_namespace_storage_limit: false)
Feature.disable(:namespace_storage_limit, group)
Feature.disable(:enforce_storage_limit_for_paid, group)
Feature.disable(:enforce_storage_limit_for_free, group)

For the under limit warning:

we'll need to set additional purchased storage, and set repository size just below the sum of repo limit and additional purchased storage


group.update(additional_purchased_storage_size: 1)
group.projects.first.statistics.update!(repository_size: 10.5.megabytes)
Rails.cache.clear

For the above limit blocking message:

Set repo size to some big value to be over all the limits

group.projects.first.statistics.update!(repository_size: 1000.megabytes)
Rails.cache.clear
To reproduce repository / namespace warning shown via `ee/app/services/ee/post_receive_service.rb` service

First, we'll need to clone a repository from your local instance.

Then we will apply relative (repository or namespace) flags and settings as shown in instructions above.

Then try to git push a change to that repository / namespace and wait for server response in the console.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Kos Palchyk

Merge request reports