Make the scheduler rate limit period an application setting

What does this MR do and why?

Moves the period of the per-project auto-remediation scheduler rate limit into the security_update_scheduler_project_period_in_seconds application setting. The default is 300, the same five minutes as today, and 0 removes the limit. The maximum is 86400, one day. Administrators can tune the limit without a deploy.

  • The setting sits in the existing dependency_management_settings hash next to security_update_scheduler_max_concurrency, so there is no migration.
  • Both scheduler rules, runs and reschedules, read their period from it.
  • With 0, limit_applies? already skips the key before any Redis call, so the scheduler has no guard of its own.
  • The limit moves from the non-configurable rate limits table to the configurable list in the rate limits docs.

References

Screenshots or screen recordings

Not applicable. There is no UI change.

How to set up and validate locally

  1. As an administrator, set the period to 60 seconds:
    curl --request PUT --header "PRIVATE-TOKEN: <admin-token>" \
      --header "Content-Type: application/json" \
      --data '{"dependency_management_settings": {"security_update_scheduler_project_period_in_seconds": 60}}' \
      "http://gdk.test:3000/api/v4/application/settings"
  2. In the Rails console, check that both rules use it:
    Gitlab::ApplicationRateLimiter::LabkitAdapter::SupportedRateLimits.period_for(:dependency_management_scheduler_run) # => 60
    Gitlab::ApplicationRateLimiter::LabkitAdapter::SupportedRateLimits.period_for(:dependency_management_scheduler_reschedule) # => 60
  3. Set the value to 0 and run two pipelines on a project with an auto-remediation profile. log/application_json.log has no DependencyManagement: scheduler run throttled line.

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.

Edited by Albina Yusupova

Merge request reports

Loading
Loading