Loading
Rate limit Direct Transfer export_relations endpoints
What does this MR do and why?
Adds rate limits to the Direct Transfer export_relations endpoints, which currently have none:
POST /projects/:id/export_relationsGET /projects/:id/export_relations/downloadPOST /groups/:id/export_relationsGET /groups/:id/export_relations/download
| Endpoint | Limit | Scope |
|---|---|---|
POST export_relations |
6/min | user + project/group |
GET export_relations/download |
20/min | user + project/group |
Notes on the approach:
- The limits are static, like
bulk_import, so there are no new ApplicationSettings. As a result they are not configurable on self-managed instances. - These are new keys, separate from
project_exportandgroup_export. File export and Direct Transfer therefore don't share a budget. - The download limit is 20/min rather than the 10/min suggested in the issue. A project migration downloads one file per NDJSON relation (about 13 to 18 per project) plus one per batch for batched relations, so 10 would throttle normal runs.
- The
/statusendpoints are not throttled.
The destination side already handles 429 responses:
BulkImports::NetworkErrortreats 429 as retriable and usesRetry-After, capped at 5 minutes, with up to 10 retries per tracker.ExportRequestWorkerretries on a failed POST.
Very large projects with many batched relations can exceed 20 downloads in a minute. Those migrations are slowed down, not broken.
Relates to #634958 Relates to #634727
Changes
lib/gitlab/application_rate_limiter/labkit_adapter/supported_rate_limits.rb: register four new ruleslib/api/project_export.rb,lib/api/group_export.rb: addcheck_rate_limit!to the four endpoints and document the429response- Request specs for throttled, non-throttled and per-portable behavior
doc/administration/instance_limits.md,doc/api/project_relations_export.md,doc/api/group_relations_export.md: document the limits and the429response
How to set up and validate locally
- Run a Direct Transfer migration of a project in GDK and confirm it completes.
- Call
POST /projects/:id/export_relationsmore than 6 times in a minute as the same user and confirm the 7th returns429. - Call the same endpoint for a different project and confirm it is not blocked.
- Repeat for
GET .../export_relations/download(more than 20 times) and for the group endpoints. - Confirm
GET .../export_relations/statusis never throttled.
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.
Related to #634958