Skip to content

Cache for ssh runner not working unless runners.builds_dir and runners.cache_dir is explicitly set

Summary

I'm using a ssh runner and tried the cache feature but it always reported Skipping cache archiving due to empty cache key at the end of the job. Based on #1686 (closed) I tried to set the option runners.builds_dir but this led to the error FATAL: open ../../../../../../../../PCAP/2017-PCa-UKD-2-Kryo-RPE-SOM/test/archive_117727464: no such file or directory Failed to create cache.

Steps to reproduce

  • setup a ssh runner and don't specify either runners.builds_dir or runners.cache_dir, something like this:
[[runners]]
  name = "runner"
  url = "https://gitlab.domain.com/"
  token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
  executor = "ssh"
  [runners.ssh]
    host = "runner.domain.com"
    port = "22"
    user = "runner"
    password = "Passw0rd"
  [runners.cache]
  • setup a CI job that uses a cache, somtehing like this:
cache:
  key: test
  paths:
    - test_cache/
job:
  script:
    - env

-> Skipping cache archiving due to empty cache key is printed at the end

  • now set the option runners.builds_dir to something in the config.toml, like this:
[[runners]]
  name = "runner"
  url = "https://gitlab.domain.com/"
  token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
  executor = "ssh"
  builds_dir = "/home/runner/builds"
  [runners.ssh]
    host = "runner.domain.com"
    port = "22"
    user = "runner"
    password = "Passw0rd"
  [runners.cache]
  • retry the job

-> error during cache creation

Creating cache test...
Runtime platform                                    arch=amd64 os=linux pid=23929 revision=cf91d5e1 version=11.4.2
test_cache/: found 2 matching files                
FATAL: open ../../../../../../../../paul.jaehne/testpaul/test/archive_618185868: no such file or directory 
Failed to create cache

(the multiple ../ lead to the root folder /)

  • now also set the option runners.cache_dir to something in the config.toml, like this:
[[runners]]
  name = "runner"
  url = "https://gitlab.domain.com/"
  token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
  executor = "ssh"
  builds_dir = "/homes/nfs/runner/builds"
  cache_dir = "/homes/nfs/runner/cache"
  [runners.ssh]
    host = "runner.domain.com"
    port = "22"
    user = "runner"
    password = "Passw0rd"
  [runners.cache]
  • retry the job

-> cache creation works as expected, but the gitlab-runner log has messages like this ERROR: Could not create cache adapter error=cache factory not found: factory for cache adapter "" was not registered when a job gets executed.

The output from env differs in CI_PROJECT_DIR. If runners.builds_dir isn't set it's relative (CI_PROJECT_DIR=builds/cf75516a/0/paul.jaehne/testpaul) and if it's set it is absolute (CI_PROJECT_DIR=/homes/nfs/runner/builds/cf75516a/0/paul.jaehne/testpaul). Setting runners.cache_dir had no effct on the output from env.

Actual behavior

The cache isn't created with the message Skipping cache archiving due to empty cache key.

Expected behavior

The cache sould be created and a reasonable default should be chosen for runners.cache_dir.

Relevant logs and/or screenshots

I can provide the build and runner log if needed, but I don't see anything useful there.

Environment description

  • Ubuntu 16.04
  • Gitlab Omnibus 11.4.6
  • group runner with ssh executor

Used GitLab Runner version

$ gitlab-runner --version
Version:      11.4.2
Git revision: cf91d5e1
Git branch:   11-4-stable
GO version:   go1.8.7
Built:        2018-10-26T20:48:10+0000
OS/Arch:      linux/amd64