Add labels to docker cache volumes
What does this MR do?
Add labels to cache volumes created by the docker executor, with job ids, pipeline ids...
Why was this MR needed?
Every resource that our Docker executor is generally labeled so that users can easily identify that the resource is managed by the Runner. The Runner creates volumes but they are not labels by the Runner.
What's the best way to test this MR?
Run a build and inspect the cache volume using docker volume inspect
What are the relevant issue numbers?
Closes #26505 (closed)
QA
- Run a build:
image: ubuntu:20.04
build1:
stage: build
script:
- echo "success!"
- Look at the logs of the runner, notice the line:
Using volume "runner-gxwcus4-project-21-concurrent-0-cache-3c3f060a0374fc8bc39395164f415a70" as cache "/cache".
- Inspect the docker volume and see that it has been labeled:
docker inspect runner-gxwcus4-project-21-concurrent-0-cache-3c3f060a0374fc8bc39395164f415a70
[
{
"CreatedAt": "2020-09-15T12:43:52Z",
"Driver": "local",
"Labels": {
"com.gitlab.gitlab-runner.job.before_sha": "8e734afb27a68436ff29b2973b05351fdd51669f",
"com.gitlab.gitlab-runner.job.id": "789",
"com.gitlab.gitlab-runner.job.ref": "master",
"com.gitlab.gitlab-runner.job.sha": "6c8eb7f4ffb1c00bd5ea92d420851b1e41052304",
"com.gitlab.gitlab-runner.pipeline.id": "84",
"com.gitlab.gitlab-runner.project.id": "21",
"com.gitlab.gitlab-runner.runner.id": "g_XWCUS4",
"com.gitlab.gitlab-runner.runner.local_id": "0",
"com.gitlab.gitlab-runner.type": "cache"
},
"Mountpoint": "/var/lib/docker/volumes/runner-gxwcus4-project-21-concurrent-0-cache-3c3f060a0374fc8bc39395164f415a70/_data",
"Name": "runner-gxwcus4-project-21-concurrent-0-cache-3c3f060a0374fc8bc39395164f415a70",
"Options": null,
"Scope": "local"
}
]
Edited by Adrien Kohlbecker