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 0 from the limit lambda 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 use staged_rule.
  • staged_rule was added in !266841 (merged).
  • With staged_rule, the authenticated key can also roll out per user, because the flag actor is scope[: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 _log rule and the :limit rule use separate Redis counters, so enabling the flag starts enforcement from zero.

References

Screenshots or screen recordings

Not applicable. No UI changes.

How to set up and validate locally

  1. In the Rails console, set ApplicationSetting.current.update!(pages_deployments_api_limit: 1).
  2. With the pages_deployments_api_rate_limit flag disabled, run the pagesDeployments GraphQL query twice. Both succeed, and the second request log line has rate_limit_state containing applimiter_pages_deployments_api:limit_pages_deployments_api_by_user_log:log.
  3. 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.

Merge request reports

Loading
Loading