Loading
Use staged_rule for pagesDeployments rate limit
What does this MR do and why?
Switches the GraphQL pagesDeployments rate limit keys (pages_deployments_api and pages_deployments_api_unauthenticated) to staged_rule. While the pages_deployments_api_rate_limit flag is disabled, the keys count and log requests over the limit without blocking them. When the flag is enabled, they enforce the limit. The resolver call site is unchanged.
Reasoning
- !267669 (merged) gated the keys by returning
0from thelimitlambda while the flag is off. The application limits guide reserves that pattern for existing keys. These keys are new and have never been enforced, so the guide says to usestaged_rule. staged_rulewas added in !266841 (merged).- With
staged_rule, the authenticated key can also roll out per user, because the flag actor isscope[:user]. The unauthenticated key is gated on:instance. - The flag name is unchanged to avoid churn in the rollout issue. Its YAML description now says the limit runs in log mode while the flag is disabled.
- The
_logrule and the:limitrule use separate Redis counters, so enabling the flag starts enforcement from zero.
References
- Follow-up to !267669 (merged)
- Pattern from !266841 (merged)
- Issue: https://gitlab.com/gitlab-org/gitlab/-/work_items/635660
- Rollout issue: #638280
Screenshots or screen recordings
Not applicable. No UI changes.
How to set up and validate locally
- In the Rails console, set
ApplicationSetting.current.update!(pages_deployments_api_limit: 1). - With the
pages_deployments_api_rate_limitflag disabled, run thepagesDeploymentsGraphQL query twice. Both succeed, and the second request log line hasrate_limit_statecontainingapplimiter_pages_deployments_api:limit_pages_deployments_api_by_user_log:log. - Enable the flag with
Feature.enable(:pages_deployments_api_rate_limit)and run the query twice. The second request returns the rate limit error.
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.