13.0.0 docker runner - ruby rejects /tmp as a tmpdir
Summary
Ruby's Dir.tmpdir throws an ArgumentError in pipelines executing in docker via gitlab runner v13.0.0. This prevents bundle install from working.
ArgumentError: could not find a temporary directory
/usr/local/lib/ruby/2.5.0/tmpdir.rb:35:in `tmpdir'
/usr/local/lib/ruby/2.5.0/tmpdir.rb:112:in `tmpdir'
/usr/local/lib/ruby/2.5.0/tmpdir.rb:120:in `create'
/usr/local/lib/ruby/2.5.0/tmpdir.rb:87:in `mktmpdir'Steps to reproduce
Environment (not sure how much of this is relevant)
- Gitlab Runner 13.0.0
- Ubuntu 18.04 host
- docker-ce 5:19.03.9
3-0ubuntu-bionic - local container image built from
ruby:2.5.8
The following repo can be used for building the container image puppet_module_testing and also for reproducing the runner error:
github.com/jessereynolds/puppet-module-testing-container
.gitlab-ci.yml
---
before_script:
- ruby -v
- bundle -v
- gem --version
- rm Gemfile.lock || true
- scripts/debug_gitlab_runner_ruby_tmpdir.rb
- bundle install --without system_tests --path /bundle --jobs $(nproc)
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
syntax:
image: puppet_module_testing:latest
script:
- bundle exec rake syntax check:symlinks check:git_ignore check:dot_underscore
variables:
PUPPET_GEM_VERSION: '~> 6'
unit:
image: puppet_module_testing:latest
script:
- bundle exec rake parallel_spec
variables:
PUPPET_GEM_VERSION: '~> 6'Actual behavior
Running bundle install or any other ruby code that tries to make a temporary directory using Dir.mktmpdir fails. In the case of this repro I've created a script in the repo that calls Dir.tmpdir directly and throws the same exception as bundle install gets:
/usr/local/lib/ruby/2.5.0/tmpdir.rb:35:in `tmpdir': could not find a temporary directory (ArgumentError)Expected behavior
/tmp should be identified by Dir.tmpdir as a valid temporary directory so that things like bundle install can proceed.
Relevant logs and/or screenshots
job log
Running with gitlab-runner 13.0.0 (c127439c)
on runner1 5zRAsbsu
Preparing the "docker" executor
00:04
Using Docker executor with image puppet_module_testing:latest ...
Using locally found image version due to if-not-present pull policy
Using docker image sha256:432091f66a87ffc8afc4ab791592858e4e13439c287f944aff7438a4cb099291 for puppet_module_testing:latest ...
Preparing environment
00:02
Running on runner-5zrasbsu-project-2-concurrent-0 via ubuntu-1804-vanilla...
Getting source from Git repository
00:02
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /tmp/cba/module_testing/.git/
From https://ps-sdp-gitlab-prod-1.it.puppet.net/cba/module_testing
* [new ref] refs/pipelines/103 -> refs/pipelines/103
eba2fa8..1657c70 master -> origin/master
Checking out 1657c703 as master...
Skipping Git submodules setup
Restoring cache
00:02
Downloading artifacts
00:02
Running before_script and script
00:02
$ ruby -v
ruby 2.5.8p224 (2020-03-31 revision 67882) [x86_64-linux]
$ bundle -v
Bundler version 2.1.4
$ gem --version
3.0.3
$ rm Gemfile.lock || true
rm: cannot remove 'Gemfile.lock': No such file or directory
$ scripts/debug_gitlab_runner_ruby_tmpdir.rb
/usr/local/lib/ruby/2.5.0/tmpdir.rb:35:in `tmpdir': could not find a temporary directory (ArgumentError)
from scripts/debug_gitlab_runner_ruby_tmpdir.rb:13:in `<main>'
"/tmp"
/tmp directory? true
/tmp writable? true
/tmp world_writable? 511
/tmp sticky? false
Running after_script
00:02
Uploading artifacts for failed job
00:02
ERROR: Job failed: exit code 1Environment description
This is a custom installation using the docker executor.
docker info:
Client:
Debug Mode: false
Server:
Containers: 2
Running: 0
Paused: 0
Stopped: 2
Images: 30
Server Version: 19.03.9
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 7ad184331fa3e55e52b890ea95e65ba581ae3429
runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
init version: fec3683
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 4.15.0-101-generic
Operating System: Ubuntu 18.04.1 LTS
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 7.791GiB
Name: ubuntu-1804-vanilla
ID: EN4M:BCGA:MTRH:DG2M:IPA6:ZWYQ:Z4QK:APG4:U7SM:E7WP:NM7O:BVXD
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: No swap limit supportconfig.toml contents
concurrent = 8
check_interval = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "runner1"
url = "https://ps-sdp-gitlab-prod-1.it.puppet.net"
token = "xxxxxxxxxxxxxxxxxxxx"
tls-ca-file = "/etc/gitlab/ssl/ps-sdp-gitlab-prod-1.it.puppet.net.crt"
executor = "docker"
builds_dir = "/tmp"
cache_dir = "/tmp"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.docker]
tls_verify = false
image = "ubuntu:bionic"
privileged = false
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/cache"]
pull_policy = "if-not-present"
shm_size = 0Used GitLab Runner version
Possible fixes
Workaround
Setting a CI/CD variable of TMPDIR to /var/tmp works around this issue.