Skip to content

Integrate StorageInlineAlert with graphql response

Ragnar Hardarson requested to merge storage-inline-alert-integration into master

What does this MR do?

Part of https://gitlab.com/gitlab-org/gitlab/-/issues/247839

Prior work:

  1. UI implementation !44494 (merged)
  2. Graphql endpoint !43837 (merged)

Screenshots

Screenshot_2020-10-13_at_15.32.45

More screenshots can be found in !44494 (merged) since we're not changing the UI here.

Testing this locally

Requires EE edition

Run the following in your bin/rails console

# Match the 10GB limit on GitLab.com
settings = Gitlab::CurrentSettings.current_application_settings
ApplicationSettings::UpdateService.new(settings, nil, {repository_size_limit: 10240}).execute


ACCESS_LEVEL_OWNER = 50
def create_group_with_usage_and_additional_storage(owner, group_name, additional_storage, usage)
  group = Group.create(name: group_name, path: group_name, type: 'Group')
  GroupMember.add_user(group, owner, ACCESS_LEVEL_OWNER)
  project = ::Projects::CreateService.new(owner, { namespace_id: group.id, name: 'project-' + group_name, path: 'project-' + group_name }).execute

  group.additional_purchased_storage_size = additional_storage
  group.save!

  project.statistics&.destroy!

  project_statistics = ProjectStatistics.new(
    project_id: project.id,
    namespace_id: group.id,
    commit_count: 12,
    repository_size: usage * 3 / 5,
    lfs_objects_size: usage * 2 / 5
  )

  project_statistics.save!
end

create_group_with_usage_and_additional_storage(root_user, 'over-free-limit', 0, 2.074e+10)
create_group_with_usage_and_additional_storage(root_user, 'under-free-limit-no-purchase', 0, 0.074e+10)
create_group_with_usage_and_additional_storage(root_user, 'over-purchased-limit', 1.074e+10, 3.074e+10)
create_group_with_usage_and_additional_storage(root_user, 'warning-with-purchase', 1.074e+10, 2.001e+10)
create_group_with_usage_and_additional_storage(root_user, 'under-free-limit-with-purchase', 1.074e+10, 0.5e+10)

Log in as root

Navigate to Usage Quota of your newly created groups, for example http://localhost:3000/groups/over-purchased-limit/-/usage_quotas#storage-quota-tab

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 Ragnar Hardarson

Merge request reports

Loading