Make Ci::JobDefinition config size limit configurable

What does this MR do and why?

Since GitLab 18.11, the compiled per-job config stored in p_ci_job_definitions was subject to a hardcoded 1 MiB size limit enforced by Ci::JobDefinition. When a job's compiled config exceeded this limit, pipeline creation failed with Config is too large. Maximum size allowed is 1 MiB, with no way to raise the limit short of a code change.

Rather than introduce a new user-facing setting, this MR resolves the Ci::JobDefinition size_limit from the existing ci_max_total_yaml_size_bytes application setting. That setting already bounds the entire pipeline configuration, and a single job's config is always a subset of it, so a single job can never exceed the total YAML size. Reusing it avoids a second, overlapping limit that would be confusing to administrators.

JsonSchemaValidator now resolves a callable size_limit, allowing Ci::JobDefinition to read the value from application settings at validation time.

Self-managed administrators who need to raise the limit for workloads that legitimately require larger per-job configs can do so by raising the existing ci_max_total_yaml_size_bytes setting, without upgrading or patching GitLab.

References

How to set up and validate locally

  1. In the Rails console, lower the limit: ApplicationSetting.update(ci_max_total_yaml_size_bytes: 10)

  2. Create a pipeline whose job config exceeds 10 bytes and confirm creation fails with a "too large" error. e.g.:

    test-job:
      variables:
        BIG_VALUE: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"  # 50+ bytes
      script:
        - echo "$BIG_VALUE"
  3. Raise the limit back to the default: ApplicationSetting.update(ci_max_total_yaml_size_bytes: 314572800)

  4. Confirm the same pipeline now creates successfully.

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 Tianwen Chen

Merge request reports

Loading