Resolve admin plan limits API plans through SystemDefined::Plan
What does this MR do and why?
Switches the admin plan limits API from Admin::PlansFinder to GitlabSubscriptions::SystemDefined::Plan, so it
reads limits by plan_name_uid.
Closes #596997 (closed)
How to set up and validate locally
-
Create a personal access token for an admin user with the
apiandadmin_modescopes. -
Change a limit on a paid plan:
curl --request PUT --header "PRIVATE-TOKEN: <token>" \ "http://gdk.test:3000/api/v4/application/plan_limits?plan_name=premium&maven_max_file_size=100"It returns
200with"maven_max_file_size": 100. -
In a Rails console, check that the row is keyed by uid and still has
plan_id:limits = PlanLimits.find_by(plan_name_uid: 5) # premium limits.maven_max_file_size # => 100 limits.plan_id == Plan.find_by(name: 'premium').id # => true -
Request a plan that has no
plansrow.freehas none unless your GDK has run as GitLab.com, so check first thatPlan.exists?(name: 'free')isfalse:curl --header "PRIVATE-TOKEN: <token>" "http://gdk.test:3000/api/v4/application/plan_limits?plan_name=free"It returns
404 Plan Not Found, the same as onmaster.
Database review
I shortened the column lists to "<table>".*.
GET /api/v4/application/plan_limits
current_plan
Before:
SELECT
"plans".*
FROM
"plans"
WHERE
"plans"."name" = 'default'
LIMIT 1Plan: https://postgres.ai/console/gitlab/gitlab-production-main/sessions/58555/commands/163548
After:
SELECT
1 AS one
FROM
"plans"
WHERE
"plans"."plan_name_uid" = 1
LIMIT 1Plan: https://postgres.ai/console/gitlab/gitlab-production-main/sessions/58555/commands/163549
actual_limits
Before:
SELECT
"plan_limits".*
FROM
"plan_limits"
WHERE
"plan_limits"."plan_id" = <plan id>
LIMIT 1Plan: https://postgres.ai/console/gitlab/gitlab-production-main/sessions/58555/commands/163550
After:
SELECT
"plan_limits".*
FROM
"plan_limits"
WHERE
"plan_limits"."plan_name_uid" = 1
LIMIT 1Plan: https://postgres.ai/console/gitlab/gitlab-production-main/sessions/58555/commands/163551
PUT /api/v4/application/plan_limits
current_plan
Before:
SELECT
"plans".*
FROM
"plans"
WHERE
"plans"."name" = 'default'
LIMIT 1Plan: https://postgres.ai/console/gitlab/gitlab-production-main/sessions/58555/commands/163548
After:
SELECT
1 AS one
FROM
"plans"
WHERE
"plans"."plan_name_uid" = 1
LIMIT 1Plan: https://postgres.ai/console/gitlab/gitlab-production-main/sessions/58555/commands/163549
actual_limits
Before:
SELECT
"plan_limits".*
FROM
"plan_limits"
WHERE
"plan_limits"."plan_id" = <plan id>
LIMIT 1Plan: https://postgres.ai/console/gitlab/gitlab-production-main/sessions/58555/commands/163550
After:
SELECT
"plan_limits".*
FROM
"plan_limits"
WHERE
"plan_limits"."plan_name_uid" = 1
LIMIT 1Plan: https://postgres.ai/console/gitlab/gitlab-production-main/sessions/58555/commands/163551
PlanLimits#set_plan_name_uid (plan has no plan_limits row yet)
Before: none.
After:
SELECT
"plans".*
FROM
"plans"
WHERE
"plans"."plan_name_uid" = 1
LIMIT 1Plan: https://postgres.ai/console/gitlab/gitlab-production-main/sessions/58555/commands/163552
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.