Skip to content

Add enforce_ci_builds_pagination_limit feature flag

Stan Hu requested to merge sh-ci-builds-pagination-limit-ff into master

What does this MR do and why?

Previously enforcement of keyset pagination for Ci::Build requests was not active. This commit adds a feature flag that will allow enforcement of offset pagination limits to prevent slow database queries.

Relates to https://gitlab.com/gitlab-com/gl-infra/reliability/-/issues/24660

How to set up and validate locally

  1. Check out this branch.
  2. Log in to your GitLab instance.
  3. In the browser, try to access: http://gdk.test:3000/api/v4/projects/1/jobs?page=600&per_page=100. This should return empty results (assuming you don't have thousands of builds).
  4. In bin/rails console, run Feature.enable(:enforce_ci_builds_pagination_limit, Project.find(YOUR-PROJECT-ID).
  5. Wait 60 seconds or so and repeat step 3. This should result in an error:
{"error":"Offset pagination has a maximum allowed offset of 50000 for requests that return objects of type Ci::Build. Remaining records can be retrieved using keyset pagination."}

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Stan Hu

Merge request reports