Truncate commit message if it breaches size limit
What does this MR do and why?
Truncate commit message if it breaches size limit
This is done to prevent job failures when the commit message is more than the limit of etcd request size.
This MR introduces a environment variable GITLAB_CI_MAX_COMMIT_MESSAGE_SIZE_IN_BYTES
which lets customers configure the maximum size of the commit message they want to pass to their CI runner. The default size is 100KB. In case the commit message breaches this limit the commit message will be truncated and a newly introduced variable CI_COMMIT_MESSAGE_IS_TRUNCATED
will be set to "true"
(default to "false"
.
This feature is currently running behind a feature flag truncate_ci_commit_message
.
References
Issue: Kubernetes Runner - large commit messages cause... (gitlab-runner#26624) • Ashvin Sharma • 18.6
Screenshots or screen recordings
Before | After |
---|---|
How to set up and validate locally
-
Trigger a pipeline with a big commit message.
# I used this command to generate a big commit message yes A | head -c 327000 | xargs > commit_msg.txt # And then used this file in the commit git commit --allow-empty -m "$(cat commit_msg.txt)" >/dev/null && git push
-
Note that runner fails because the commit message is too big
-
Run the rails server with environment variable
GITLAB_CI_MAX_COMMIT_MESSAGE_SIZE_IN_BYTES
value equal to1000
(This is kept low to show the effect) -
In rails console enable the feature flag
Feature.enable(:truncate_ci_commit_message)
-
Trigger a pipeline with a big commit message.
-
You should see a new environment variable
CI_COMMIT_MESSAGE_IS_TRUNCATED
set to'true'
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.