Seed the job variable count limit behind a feature flag

What does this MR do and why?

Sets the ci_job_variables_count plan limit to 200 on GitLab.com, and puts the job variable limits behind the ci_job_variable_limits feature flag. The limits are checked when a user runs or retries a manual job with variables.

The seed sets the limit on free, bronze, silver, premium, gold, ultimate, ultimate_trial, ultimate_trial_paid_customer, premium_trial and opensource.

  • It runs only when Gitlab.com? is true, so GitLab Self-Managed and GitLab Dedicated do not change.
  • default is left out. On GitLab.com a namespace without a subscription falls back to free, so this leaves no gap.
  • early_adopter is left out. The internal note on this MR has the reason, and the usage that supports 200.
  • It is a post-deployment migration, so the flag is deployed before the limit is set.
  • It runs without a transaction. On GitLab.com, create_or_update_plan_limit also upserts the plans row, so each call writes two tables, and the multiple-locks check rejects that in one transaction. Each upsert is idempotent, so a partial run can be repeated.

Feature flag

ci_job_variable_limits is a beta flag, enabled by default, with the top-level namespace as actor. It gates the count check and both size checks for job variables. Turning it off through ChatOps is faster than setting a plan limit back to 0 on GitLab.com.

With the flag off, a request over a limit is accepted. Every request over a limit is logged as Job variables exceed a plan limit, and extra.rejected shows whether it was blocked.

The flag is already set to false on GitLab.com, before this MR is merged. Flag state is stored by name, so it can be set before the flag definition is deployed, and a stored state wins over default_enabled. The commands are in the rollout issue. After this MR is deployed:

  • On GitLab.com, nothing is blocked until the flag is enabled through the rollout issue. This includes the size checks, which are enforced today. The rejected: false logs show what would be blocked.
  • On GitLab Self-Managed and GitLab Dedicated, the flag is enabled by default, so the size checks stay enforced. The count limit stays 0 there, so nothing changes.

The GitLab.com docs already list 200 for job variables, so the docs change only adds the flag history.

References

Screenshots or screen recordings

Not applicable. No UI change.

How to set up and validate locally

  1. Run bin/rails db:migrate without GITLAB_SIMULATE_SAAS. The seed changes nothing.
  2. Run bin/rails db:migrate:down:main VERSION=20261117134520, then GITLAB_SIMULATE_SAAS=1 bin/rails db:migrate.
  3. In GITLAB_SIMULATE_SAAS=1 bin/rails console, check the values: Plan.all.map { |p| [p.name, p.actual_limits.ci_job_variables_count] }. The seeded plans show 200 and default shows 0.
  4. Run GITLAB_SIMULATE_SAAS=1 bin/rails db:migrate:down:main VERSION=20261117134520 and check that the seeded plans show 0 again.
  5. Set Plan.default.actual_limits.update!(ci_job_variables_count: 1) and run a manual job with two variables. The job does not run.
  6. Run Feature.disable(:ci_job_variable_limits) and run the job again. The job runs, and log/application_json.log has a Job variables exceed a plan limit entry with "rejected":false.

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 Furkan Ayhan

Merge request reports

Loading
Loading