Surface error when needed job name exceeds length limit in CI pipeline
What does this MR do and why?
Background context:
Given a parallel job defined like so:
base_job_name:
script: echo
parallel: 1
its job name will be expanded to base_job_name 1/1
.
Given a parallel job with matrix defined:
base_job_name:
script: echo
parallel:
matrix:
- VAR1: a
its job name will be expanded to base_job_name: [a]
. If multiple variables are defined ({VAR1: a, VAR2: b}
), the name will be expanded to base_job_name: [a, b]
.
Problem:
Currently, no validation error appears when a job needs
a parallel job whose expanded name exceeds the limit of 128 characters. Instead, the pipeline fails to be created without any error message as described in #362262 (closed).
Fix:
This MR surfaces this validation error. Additional notes:
- The limit is already documented (under "Additional details:").
- While this validation check is not specific to parallel jobs, it will be the most common case for this error since the expanded names of parallel jobs aren't visible in the pipeline editor.
- Adding a validation in the
Entry::Need
class is not sufficient for a couple reasons:- The length limit is intended to be increased to match the job name length limit (255 characters) in Step 2 of #362262 (closed). Since you can't
need
a non-existent job name, this length limit will already be covered by the job entry validation. - Entry class validations happen before a parallel job's name is fully expanded in
Ci::Config::Normalizer
.
- The length limit is intended to be increased to match the job name length limit (255 characters) in Step 2 of #362262 (closed). Since you can't
Resolves Step 1 of #362262 (closed)
Screenshots or screen recordings
Validation error is now detected. Examples:
Example 1: Needing a non-parallel job whose name is too long.
129-chars_iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii:
script: echo
child-job:
script: echo
needs:
- 129-chars_iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
Before | After |
---|---|
Example 2: Needing a parallel job whose base name is too long.
125-chars_iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii:
script: echo
parallel: 2
child-job:
script: echo
needs:
- 125-chars_iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
Before | After |
---|---|
Example 3: Needing a parallel job whose single matrix value is too long.
parent-job:
script: echo
parallel:
matrix:
- VAR1: 115-chars_iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
child-job:
script: echo
needs:
- parent-job
Before | After |
---|---|
Example 4: Needing a parallel job whose multiple matrix values are too long.
parent-job:
script: echo
parallel:
matrix:
- VAR1: 60-chars_iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
VAR2: 53-chars_iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
child-job:
script: echo
needs:
- parent-job
Before | After |
---|---|
How to set up and validate locally
For each of the examples in the above section:
- In your project's pipeline editor, update your
.gitlab-ci.yml
file with the example content. - Observe that the validation error is caught in the pipeline editor as well as when running the pipeline.
- (Optional) Observe that if you reduce the long name or variable value by 1 character, there are no validation errors and the pipeline runs successfully.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #362262 (closed)