Gitlab-Runner Short sha length should be 8 characters instead of 9
Summary
-
Expected Short sha Length of Gitlab-Runner is 8 characters across all projects but
app/models/ci/runner.rbcrops it to 9 characters instead, this causes confusion as it becomes challenging to locate Prometheus metrics when searching for the longer version. -
The runner's token length changed from 8 to 9 characters due to this commit 18145874
-
- this is due to the fact that
token[start_index..start_index + 8]is an inclusive range instead oftoken[0..0 + 8]which uses an extra character that will be included => thus resulting in an extra character and 9 instead of 8 characters
- this is due to the fact that
-
Thanks @ghostlyrics for reporting this in gitlab-runner#36908
Steps to reproduce
- Create empty Gitlab project (tested with version
- Create a Gitlab-Runner
- Check the length displayed inside https://gitlab-address/root/test/-/runners/1
Example Project
What is the current bug behavior?
- Gitlab-runner short sha length is 9 characters long (where it is applied from
app/models/ci/runner.rb)
What is the expected correct behavior?
- Gitlab-runner short sha length should be 8 characters across all projects.
Relevant logs and/or screenshots
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
System information System: Current User: git Using RVM: no Ruby Version: 3.0.6p216 Gem Version: 3.4.19 Bundler Version:2.4.19 Rake Version: 13.0.6 Redis Version: 7.0.13 Sidekiq Version:6.5.7 Go Version: unknown GitLab information Version: 16.4.1 Revision: e6801ed8d44 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: PostgreSQL DB Version: 13.11 URL: http://192.168.111.178 HTTP Clone URL: http://192.168.111.178/some-group/some-project.git SSH Clone URL: ssh://git@192.168.111.178:2222/some-group/some-project.git Using LDAP: no Using Omniauth: yes Omniauth Providers: GitLab Shell Version: 14.28.0 Repository storages: - default: unix:/var/opt/gitlab/gitaly/gitaly.socket GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell Gitaly - default Address: unix:/var/opt/gitlab/gitaly/gitaly.socket - default Version: 16.4.1 - default Git Version: 2.42.0
Results of GitLab application Check
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:check SANITIZE=true)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)(we will only investigate if the tests are passing)
Possible fixes
- Account for the inclusive range by changing it's length to 7.
- See Branch
fix-gitlab-runner-short-sha-lengthfrom https://gitlab.com/eth7/gitlab/-/tree/fix-gitlab-runner-short-sha-length
Edited by Christian N

