Rate limit standards adherence refresh mutation
What does this MR do and why?
The refreshStandardsAdherenceChecks GraphQL mutation enqueues ComplianceManagement::Standards::RefreshWorker, which fans out to jobs for every project in the group hierarchy. The mutation had no rate limit.
This MR adds two limits to the mutation, checked after authorization:
| Rule | Limit | Key |
|---|---|---|
compliance_standards_adherence_refresh_per_user |
10 per hour | user |
compliance_standards_adherence_refresh_per_group |
1 per hour | the refreshed group (not the root, so sibling subgroups are independent) |
- Calls are not counted while the group's 24-hour refresh tracker is set. Those calls enqueue no checks and only return the progress, so API clients can keep polling.
- Both rules use
staged_rule: untilcompliance_standards_refresh_rate_limitis enabled, hits are only logged (rate_limit_state). This lets us check real hit rates on GitLab.com before enforcing. - Requests over the limit return
This endpoint has been requested too many times. Try again later.in the mutation'serrorsfield, likeResyncSecurityPolicies. - No frontend code calls this mutation.
- Adds a row to
doc/rate_limits/non_configurable.md.
References
Screenshots or screen recordings
Not applicable: no UI changes.
How to set up and validate locally
-
In the Rails console, enable the flag:
Feature.enable(:compliance_standards_refresh_rate_limit) -
As a group owner, run this mutation twice in GraphiQL (
http://gdk.test:3000/-/graphql-explorer) with Sidekiq stopped (gdk stop rails-background-jobs), so the refresh tracker isn't set:mutation { refreshStandardsAdherenceChecks(input: { groupPath: "<group-path>" }) { errors adherenceChecksStatus { totalChecks checksCompleted } } } -
The second call returns the rate limit error in
errors. A refresh of another group still works. -
Disable the flag and repeat: both calls succeed.
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.