Make trial and hand-raise lead rate limits configurable
What does this MR do and why?
The trial_create and hand_raise_lead_create rate limits are hard-coded at 10 requests per hour for each user. This adds the trial_create_limit and hand_raise_lead_create_limit application settings (in the rate_limits jsonb column) with the same defaults, so admins can raise or disable them through the settings API without a deploy. Setting either to 0 disables that limit.
This follows the pattern from !268308 (merged). Enforcement is still behind enforce_trial_create_rate_limit and enforce_hand_raise_lead_rate_limit until those flags are removed. This MR should merge first, so setting a limit to 0 stays available as the off switch.
Both limits only apply on GitLab.com. Trial creation is only routed when subscriptions_trials is available, and hand-raise leads return 404 unless gitlab_com_subscriptions is available. That's why they keep a default of 10 instead of 0 like the 19.6 Self-Managed fixes - !271238.
References
- https://gitlab.com/gitlab-org/gitlab/-/work_items/635543
- https://gitlab.com/gitlab-org/gitlab/-/work_items/636612
- #636797
Screenshots or screen recordings
No UI changes. Like the GitLab Credits limits, these are API-only settings.
How to set up and validate locally
- In a rails console, check the defaults:
Gitlab::ApplicationRateLimiter::LabkitAdapter::SupportedRateLimits.limit_for(:trial_create) # => 10 - Update a limit as an admin:
curl --request PUT --header "PRIVATE-TOKEN: <admin token>" \ "http://gdk.test:3000/api/v4/application/settings?trial_create_limit=20" - Re-run the console check. It returns
20.
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.