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_relations
  • GET /projects/:id/export_relations/download
  • POST /groups/:id/export_relations
  • GET /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_export and group_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 /status endpoints are not throttled.

The destination side already handles 429 responses:

  • BulkImports::NetworkError treats 429 as retriable and uses Retry-After, capped at 5 minutes, with up to 10 retries per tracker.
  • ExportRequestWorker retries 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 rules
  • lib/api/project_export.rb, lib/api/group_export.rb: add check_rate_limit! to the four endpoints and document the 429 response
  • 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 the 429 response

How to set up and validate locally

  1. Run a Direct Transfer migration of a project in GDK and confirm it completes.
  2. Call POST /projects/:id/export_relations more than 6 times in a minute as the same user and confirm the 7th returns 429.
  3. Call the same endpoint for a different project and confirm it is not blocked.
  4. Repeat for GET .../export_relations/download (more than 20 times) and for the group endpoints.
  5. Confirm GET .../export_relations/status is 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

Merge request reports

Loading
Loading