Misleading documentation leading to non-functioning cache
Summary
When following the Job configuration documentation and adding a cache-key from it, the cache will fail silently. This seems to be true for any key that does not meet the requirements (especially about not containing a "/").
The documentation explicitly states to use $CI_COMMIT_REF_NAME
- but that name can contain illegal characters, when the branch name is e.g. feature/some-new-thing
.
Proposed solution
-
fix the executor to not silently ignore invalid keys -
fix the documentation to use "${CI_COMMIT_REF_SLUG}"
instead of the wrong"${CI_COMMIT_REF_NAME}"
(see gitlab-ce!17047)
Steps to reproduce
- This was tested for gitlab-multi-runner 10.4 with kubernetes executor
- open a new branch with a compound key like "feature/12345"
- Add the following cache-key to any
.gitlab-ci.yml
according to the documentation:
cache:
key: "$CI_COMMIT_REF_NAME"
Actual behavior
The executor log does not show any sign of a cache setting or a problem hinting on an invalid key.
Expected behavior
The executor should ignore the cache, but put out a warning.
Relevant logs and/or screenshots
## the log of a correct run
Running on gitlab/runner-abcdefg-project-123-concurrent-123456 via gitlab-runner-123456-987654...
Cloning repository for feature/gitlab-cache with git depth set to 1...
Cloning into '/group/project'...
Checking out b1348594 as feature/gitlab-cache...
Skipping Git submodules setup
Checking cache for feature/gitlab-cache...
Downloading cache.zip from http://minio-service:9000/runner/runner/abcdefg/project/123/feature/gitlab-cache
Successfully extracted cache
$ docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
Login Succeeded
[...snip...]
Creating cache feature/gitlab-cache...
node_modules/: found 26281 matching files
Uploading cache.zip to http://minio-service:9000/runner/runner/abcdefg/project/123/feature/gitlab-cache
Created cache
## the log of an *actual* run (current behavior)
Running on gitlab/runner-abcdefg-project-123-concurrent-123456 via gitlab-runner-123456-987654...
Cloning repository for feature/gitlab-cache with git depth set to 1...
Cloning into '/group/project'...
Checking out b1348594 as feature/gitlab-cache...
Skipping Git submodules setup
$ docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
Login Succeeded
[...snip...]
Job succeeded
## what I would expect the log to look like
Running on gitlab/runner-abcdefg-project-123-concurrent-123456 via gitlab-runner-123456-987654...
Cloning repository for feature/gitlab-cache with git depth set to 1...
Cloning into '/group/project'...
Checking out b1348594 as feature/gitlab-cache...
Checking cache for feature/gitlab-cache...
Warning: Invalid cache key found, ignoring.
Skipping Git submodules setup
$ docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
Login Succeeded
[...snip...]
Job succeeded
Environment description
- Custom gitlab installation 10.4.3
- gitlab-runner 10.4.0
- gitlab-executor kubernetes
- Kubernetes 1.8.6
Edited by Lars Kumbier