Skip to content

Resolve "Add subscription table to GitLab.com billing areas"

What does this MR do?

Instead of showing the promotion table on the group namespaces we will display a subscription table showing information about the user's current usage and billing state.

CE-port: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/23264

Screenshots:

before after
promotion_table_old subscription_table_new

Backend changes

  • Adds a new model: GitlabSubscription

    • This model will be used to store all the info related to a GitLab.com subscription or a GitLab EE subscription.
  • Adds the following API endpoints

    • POST https://gitlab.example.com/api/v4/namespaces/:id/gitlab_subscription
      • This endpoint creates a new GitLab subscription for the current namespace (can be a Group or User).
      • This endpoint can be used only with an admin token. For now this is only going to be used by the subscription portal every time a new subscription is purchased. The subscription portal will sync all the info related to the subscription: the number of purchased seats, the purchased plan, start and end date of the subscription and whether the subscription is trial or not.
    • GET https://gitlab.example.com/api/v4/namespaces/:id/gitlab_subscription
      • Returns the serialized GitLab Subscription resource that belongs to the current namespace. This endpoint can only be accessible by the owner of the namespace or the admin user.
    • PUT https://gitlab.example.com/api/v4/namespaces/:id/gitlab_subscription
      • This endpoint allows the client to update any attribute of the GitLab subscription resource.
  • Adds a new background job that will be executed daily through a cronjob.

    • The purpose of this worker is to update the max_seats_used attribute of the GitLab subscription with the current number of active users. max_seats_user is only going to be updated if the current number of active users is greater than the current value of max_seats_used
    • The value of max_seats_used will be used to show the customer how many extra seats they have added on top of the seats allowed by the subscription. Our plan is to do an automatic charge of those extra seats on a monthly basis.

Local GDK setup

In order to activate the Billing menu item on the following pages

one needs to make sure to return true from the following methods on the local GDK:

  • self.dev_env_or_com? (in gitlab.rb)
  • should_check_namespace_plan? (in application_setting.rb)

One can update a particular group to a different plan via the rails console:

plan = Plan.find_by_name('bronze')
group = Group.find_by_path('gitlab-org')
group.create_gitlab_subscription!(hosted_plan: plan, seats: 100, start_date: Date.today, end_date: 1.year.from_now.to_date)

What are the relevant issue numbers?

https://gitlab.com/gitlab-org/gitlab-ee/issues/7772

Does this MR meet the acceptance criteria?

Closes #7772 (closed)

Edited by Mark Chao

Merge request reports