Skip to content

Use CliNotification in PostReceiveService

Mohamed Hamda requested to merge UseCliNotificationInPostReceiveService into master

What does this MR do and why?

This is the second MR to close https://gitlab.com/gitlab-org/gitlab/-/issues/360326

This MR is using the newly introduced CliNotification class in !108327 (merged)

How to set up and validate locally

  1. Make sure the automatic_purchased_storage_allocation and enforce_namespace_storage_limit application settings are both enabled (true).
gitlabhq_development=# SELECT automatic_purchased_storage_allocation, enforce_namespace_storage_limit FROM application_settings;
 automatic_purchased_storage_allocation | enforce_namespace_storage_limit 
----------------------------------------+---------------------------------
 t                                      | t
(1 row)

gitlabhq_development=# 
  1. Enable the following feature flags in a rails console.
[1] pry(main)> Feature.enable(:namespace_storage_limit)
[...]
[2] pry(main)> Feature.enable(:enforce_storage_limit_for_paid)
[...]
[3] pry(main)> Feature.enable(:enforce_storage_limit_for_free)
[...]
[4] pry(main)> Feature.enable(:namespace_storage_limit_bypass_date_check)

Testing updated messages locally

  • Pick any project in your local GitLab instance,
  • Clone the project.
  • In the example here, my project is "Wget2" under the "Gnuwget" Group
  • We should override def current_size and def limit in ee/app/models/namespaces/storage/root_size.rb

To test the warning message:

Apply the following changes to your local GitLab instance in ee/app/models/namespaces/storage/root_size.rb.

For warning messages:

def current_size
 7680000
end

def limit
 8000000
end
$ git checkout -b my-test-branch   
$ echo 'change file' > README.md 
$ git add .
$ git commit -m "Pushing warning" 
$ git push 

This should give you the following warning message:

Screenshot_2023-02-03_at_19.22.14

To test the error message:

Apply the following changes to your local GitLab instance in ee/app/models/namespaces/storage/root_size.rb.

def current_size
 8000000
end

def limit
 7680000
end
$ git checkout -b my-test-branch   
$ echo 'change file' > README.md 
$ git add .
$ git commit -m "Pushing errors" 
$ git push 

This should give you the following error message:

Screenshot_2023-02-03_at_19.23.22

MR acceptance checklist

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

Merge request reports