Environment slug suffix added when string case is different
Summary
When using an upper case environment name like QA
, the resulting environment slug will contain a suffix of random characters. This does not occur when using a lower case environment name like qa
.
The truncation of the Environment slug is to ensure that the resulting environment slug is 24 characters long. If there was truncation, the first 0..16
characters are used from the original "slugified" string, with the remaining 6 bytes being random string to avoid collisions.
It will currently truncate if the "slugified" environment name doesn't match the original, regardless of size: https://gitlab.com/gitlab-org/gitlab/-/blob/916d24d1e48ad1353242f5740465c849586b0c8d/lib/gitlab/slug/environment.rb#L29
If the original downcase
operation changed the case, this will automatically mean that the "slugified" environment name is different.
https://gitlab.com/gitlab-org/gitlab/-/blob/916d24d1e48ad1353242f5740465c849586b0c8d/lib/gitlab/slug/environment.rb#L21
If this is expected behaviour, we should document this.
Steps to reproduce
- Create a CI/CD pipeline job that deploys to an environment of name
QA
. Observe theCI_ENVIRONMENT_SLUG
variable value - Create a CI/CD pipeline job that deploys to an environment of name
qa
. Observe theCI_ENVIRONMENT_SLUG
variable value
Example Project
https://gitlab.com/gitlab-gold/tmike/zd418938/zd418938/-/jobs/4485089826 https://gitlab.com/gitlab-gold/tmike/zd418938/zd418938/-/jobs/4485086410
What is the current bug behavior?
If the environment name contains upper-case characters, the suffix is added to the slug
What is the expected correct behavior?
The suffix is added to the slug if it's been truncated due to being too long
Relevant logs and/or screenshots
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
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)