Skip to content

Draft: Added overwrite for authorize_create_package

What does this MR do and why?

Returns a meaningful response when over_storage_limit condition is true for package curl

Ref: https://gitlab.com/gitlab-org/gitlab/-/issues/366869

Screenshots or screen recordings

These are strongly recommended to assist reviewers and reduce the time to merge your change.

How to set up and validate locally

Validate "pushing a package artifact" when over_storage_limit? is false

  1. Created a test project on my local server, (no storage breached yet)
  2. Created an personal auth token for api
  3. Try to upload a generic package using curl to validate "pushing a package artifact" is working fine
➜  gitlab git:(issue_348728_locking_package_registry) ✗ curl --header "PRIVATE-TOKEN:-R--yUNzYSixMsUxZRJW" \
     --upload-file /Users/surajtripathi/test.txt \
     "http://127.0.0.1:3000/api/v4/projects/20/packages/generic/my_package/0.0.1/test.txt" | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    45  100    25  100    20     34     27 --:--:-- --:--:-- --:--:--    61
{
  "message": "201 Created"
}

Validate "pushing a package artifact" when over_storage_limit? is true

  1. Modify over_storage_limit? locally(for testing purposes), to return true
  2. Try to upload a generic package using curl to validate "pushing a package artifact" is blocked
➜  gitlab git:(issue_366869_error_message_fix_for_package_api) ✗ curl --header "PRIVATE-TOKEN:-R--yUNzYSixMsUxZRJW" \
     --upload-file /Users/surajtripathi/test.txt \
     "http://127.0.0.1:3000/api/v4/projects/20/packages/generic/my_package/0.0.1/test.txt" | jq

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
 90   205  100   185    0     0    221      0 --:--:-- --:--:-- --:--:--   223
{
  "message": "403 Forbidden - Storage Limit Breached! Cannot perform this action.You are above your storage quota! Visit https://docs.gitlab.com/ee/user/usage_quotas.html to learn more."
}

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 Suraj Tripathi

Merge request reports

Loading