[Provision alignment] Create new API endpoint for new namespace provisioning logic

Problem

The current provisionings for GitLab.com and SM/Dedicated follow markedly distinct approaches. While SM/Dedicated relies on licenses (license key or file) to contain all needed info, GitLab.com relies on multiple syncs for a namespace.

To align the provision between the deployment types, the GitLab.com provisioning will be aligned to be similar to the SM/Dedicated. The current multiple syncs to GitLab.com will be replaced by a single sync for a namespace which includes all needed information at once. Each sync will be stored in the database on the CustomersDot side for easier auditing. These records will follow a similar behavior as the license generation for SM/Dedicated and only create a new entry for a sync if the data/info for the new sync has changed compared to the last sync. Timestamps for each sync will still be stored for a better insight into the sync frequency.

On the GitLab side as much logic as possible will be reused to provision the received info. A future iteration could focus on simplifying the GitLab.com side's provisioning. The provisioning will happen directly when receiving the request due to the async part being on the CDot side.

Proposal

Create a new GitlabSubscription internal endpoint to do complete sync for the namespace.

POST POST /api/v4/internal/gitlab_subscriptions/namespaces/:id/provision

API Contract

A new internal endpoint will be created on GitLab that will do full provision of the namespace.

POST /api/v4/internal/gitlab_subscriptions/namespaces/:id/provision

The endpoint will accept following JSON body structure:

Notes: all params are optional.

{
  "provision": {
    "main_plan": {
      "plan_code": "string_value",
      "start_date": "2023-06-01",
      "end_date": "2024-05-31",
      "seats": 100,
      "max_seats_used": 90,
      "trial": false,
      "trial_starts_on": "2023-07-01",
      "trial_ends_on": "2024-07-01",
      "auto_renew": true
    },
    "compute_minutes": {
      "shared_runners_minutes_limit": 50000,
      "extra_shared_runners_minutes_limit": 10000,
      "packs": [
        {
          "purchase_xid": "purchase_1",
          "number_of_minutes": 5000,
          "expires_at": "2023-12-31"
        },
        {
          "purchase_xid": "purchase_2",
          "number_of_minutes": 5000,
          "expires_at": "2024-06-30"
        }
      ]
    },
    "storage": {
      "additional_purchased_storage_size": 1000,
      "additional_purchased_storage_ends_on": "2024-05-31"
    },
    "add_on_purchases": {
      "duo_pro": [
        {
          "quantity": 100,
          "started_on": "2023-06-01",
          "expires_on": "2024-05-31",
          "purchase_xid": "purchase_123",
          "trial": false
        }
      ]
    }
  }
}

Response:

  1. 200 : Successful Request ✅
  2. 422 : Unprocessable Entity ⚠️
  3. 401 : Unauthorized Request 🔐
  4. 404 : Namespace not found 🤷
  5. 500: Server Error 💥

Result

Dedicated API endpoint to provision a namespace via a single sync.

Edited Feb 11, 2025 by Bishwa Hang Rai
Assignee Loading
Time tracking Loading