Skip to content

Display Total Namespace Storage with Cost Factor on Usage Quotas Page

What does this MR do and why?

Display the total namespace storage taking into account any cost factor for forks on the Usage quotas page.

Screenshots or screen recordings

Before

Screenshot_2023-07-05_at_11.33.09_PM

After

With a cost factor for forks of 0.1, the total namespace storage is reduced by about 900 kilobytes. This is because there is one fork in the namespace of about 1000 KB in size. (There are actually two forks, however the cost factor only applies to one of them, because this is a free namespace and one of the forks is private.)

Screenshot_2023-07-05_at_11.33.36_PM

How to set up and validate locally

  1. Enable namespace storage limits.

  2. Edit the Namespaces::Storage::RootSize::COST_FACTOR_FOR_FORKS constant to be something between 0 and 1:

diff --git a/ee/app/models/namespaces/storage/root_size.rb b/ee/app/models/namespaces/storage/root_size.rb
index cd3768efc211..4f474d273cc1 100644
--- a/ee/app/models/namespaces/storage/root_size.rb
+++ b/ee/app/models/namespaces/storage/root_size.rb
@@ -6,7 +6,7 @@ class RootSize
       CURRENT_SIZE_CACHE_KEY = 'root_storage_current_size'
       EXPIRATION_TIME = 10.minutes
       LIMIT_CACHE_NAME = 'root_storage_size_limit'
-      COST_FACTOR_FOR_FORKS = 1.0
+      COST_FACTOR_FOR_FORKS = 0.1
       COST_FACTOR = 1.0
 
       def initialize(root_namespace)
  1. Visit the Usage quotas page. The total Namespace storage used should be reduced in accord with the storage discount for forks. You will need forks in your namespace to see this effect.

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 Jason Goodman

Merge request reports