gitlab-runner v13.0.1 panic for "runtime error: index out of range [1] with length 1"
Summary
gitlab-runner v13.0.1 panic for "runtime error: index out of range [1] with length 1" at the stage of Preparing environment
the gitlab-runner is in docker mode, installed at the same host as gitlab server.
Steps to reproduce
we have simplified our CI/CD as following
.gitlab-ci.yml
################################
#
# the executor must have socket binding
#
################################
image: docker:stable
stages:
- basic
gradle:
stage: basic
tags:
- docker_socket
script:
- echo "hello world"
the CI/CD flow just stopped at the Preparing environment
while the docker container is already stopped.
the job log reads as:
job log
Running with gitlab-runner 13.0.1 (21cb397c)
on docker-socket CxMj2wKw
Preparing the "docker" executor
Using Docker executor with image docker:stable ...
WARNING: Container based cache volumes creation is disabled. Will not create volume for "/cache"
Pulling docker image docker:stable ...
Using docker image sha256:0bfe00e7bcd536451161fd64b2fe05f4ff6373ce9dd241e9762b68c7f56ce438 for docker:stable ...
Preparing environment
then we run gitlab-runner in debug mode, and found it has a panic during environment preparation.
the log reads as
gitlab-runner log
hduser@hduser-HP-Z820-Workstation:~$ sudo gitlab-runner --debug run -c /etc/gitlab-runner/config.toml
Runtime platform arch=amd64 os=linux pid=18652 revision=21cb397c version=13.0.1
Starting multi-runner from /etc/gitlab-runner/config.toml... builds=0
Checking runtime mode GOOS=linux uid=0
Running in system-mode.
Configuration loaded builds=0
listenaddress: ""
sessionserver:
listenaddress: ""
advertiseaddress: ""
sessiontimeout: 1800
concurrent: 1
checkinterval: 0
loglevel: null
logformat: null
user: ""
runners:
- name: ci-runner
limit: 0
outputlimit: 409600
requestconcurrency: 0
runnercredentials:
url: https://192.168.0.60/
token: s2cNzs5hCE3diWmAQ85C
tlscafile: /etc/gitlab-runner/my-root.crt
tlscertfile: ""
tlskeyfile: ""
runnersettings:
executor: docker
buildsdir: ""
cachedir: ""
cloneurl: https://192.168.0.60/
environment: []
preclonescript: ""
prebuildscript: ""
postbuildscript: ""
debugtracedisabled: false
shell: ""
custombuilddir:
enabled: false
referees: null
cache:
type: ""
path: ""
shared: false
s3:
serveraddress: ""
accesskey: ""
secretkey: ""
bucketname: ""
bucketlocation: ""
insecure: false
gcs:
cachegcscredentials:
accessid: ""
privatekey: ""
credentialsfile: ""
bucketname: ""
ssh: null
docker:
credentials:
host: ""
certpath: ""
tlsverify: false
hostname: ""
image: alpine
runtime: ""
memory: ""
memoryswap: ""
memoryreservation: ""
cpusetcpus: ""
cpus: ""
cpushares: 0
dns: []
dnssearch: []
privileged: true
disableentrypointoverwrite: false
usernsmode: ""
capadd: []
capdrop: []
oomkilldisable: false
oomscoreadjust: 0
securityopt: []
devices: []
disablecache: true
volumes:
- /cache
volumedriver: ""
cachedir: ""
extrahosts: []
volumesfrom: []
networkmode: ""
links: []
services: []
waitforservicestimeout: 0
allowedimages: []
allowedservices: []
pullpolicy: ""
shmsize: 0
tmpfs: {}
servicestmpfs: {}
sysctls: {}
helperimage: ""
parallels: null
virtualbox: null
machine: null
kubernetes: null
custom: null
- name: docker-socket
limit: 0
outputlimit: 0
requestconcurrency: 0
runnercredentials:
url: https://192.168.0.60/
token: CxMj2wKwpMa8okrZA4dx
tlscafile: /etc/gitlab-runner/my-root.crt
tlscertfile: ""
tlskeyfile: ""
runnersettings:
executor: docker
buildsdir: ""
cachedir: ""
cloneurl: https:/192.168.0.60/
environment: []
preclonescript: ""
prebuildscript: ""
postbuildscript: ""
debugtracedisabled: false
shell: ""
custombuilddir:
enabled: false
referees: null
cache:
type: ""
path: ""
shared: false
s3:
serveraddress: 192.168.0.60:9005
accesskey: minio
secretkey: minio123
bucketname: gitlab-runner
bucketlocation: ""
insecure: true
gcs:
cachegcscredentials:
accessid: ""
privatekey: ""
credentialsfile: ""
bucketname: ""
ssh: null
docker:
credentials:
host: ""
certpath: ""
tlsverify: false
hostname: ""
image: alpine
runtime: ""
memory: ""
memoryswap: ""
memoryreservation: ""
cpusetcpus: ""
cpus: ""
cpushares: 0
dns: []
dnssearch: []
privileged: true
disableentrypointoverwrite: false
usernsmode: ""
capadd: []
capdrop: []
oomkilldisable: false
oomscoreadjust: 0
securityopt: []
devices: []
disablecache: true
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /cache
volumedriver: ""
cachedir: ""
extrahosts: []
volumesfrom: []
networkmode: ""
links: []
services: []
waitforservicestimeout: 0
allowedimages: []
allowedservices: []
pullpolicy: ""
shmsize: 0
tmpfs: {}
servicestmpfs: {}
sysctls: {}
helperimage: ""
parallels: null
virtualbox: null
machine: null
kubernetes: null
custom: null
sentrydsn: null
modtime: 2020-06-02T11:05:47.501999067+08:00
loaded: true
builds=0
Waiting for stop signal builds=0
listen_address not defined, metrics & debug endpoints disabled builds=0
[session_server].listen_address not defined, session endpoints disabled builds=0
Feeding runners to channel builds=0
Starting worker builds=0 worker=0
Trying to load /etc/gitlab-runner/my-root.crt ...
Dialing: tcp 192.168.0.60:443 ...
Checking for jobs... nothing runner=s2cNzs5h
Trying to load /etc/gitlab-runner/my-root.crt ...
Dialing: tcp 192.168.0.60:443 ...
Checking for jobs... nothing runner=CxMj2wKw
Feeding runners to channel builds=0
Checking for jobs... nothing runner=s2cNzs5h
Checking for jobs... received job=209 repo_url=https://192.168.0.60/devops/dockers.git runner=CxMj2wKw
Failed to requeue the runner builds=1 runner=CxMj2wKw
Running with gitlab-runner 13.0.1 (21cb397c) job=209 project=5 runner=CxMj2wKw
on docker-socket CxMj2wKw job=209 project=5 runner=CxMj2wKw
Preparing the "docker" executor job=209 project=5 runner=CxMj2wKw
Shell configuration: environment: []
dockercommand:
- sh
- -c
- "if [ -x /usr/local/bin/bash ]; then\n\texec /usr/local/bin/bash \nelif [ -x /usr/bin/bash
]; then\n\texec /usr/bin/bash \nelif [ -x /bin/bash ]; then\n\texec /bin/bash \nelif
[ -x /usr/local/bin/sh ]; then\n\texec /usr/local/bin/sh \nelif [ -x /usr/bin/sh
]; then\n\texec /usr/bin/sh \nelif [ -x /bin/sh ]; then\n\texec /bin/sh \nelif [
-x /busybox/sh ]; then\n\texec /busybox/sh \nelse\n\techo shell not found\n\texit
1\nfi\n\n"
command: bash
arguments: []
passfile: false
extension: ""
job=209 project=5 runner=CxMj2wKw
Using Docker executor with image docker:stable ... job=209 project=5 runner=CxMj2wKw
Looking for prebuilt image gitlab/gitlab-runner-helper:x86_64-21cb397c... job=209 project=5 runner=CxMj2wKw
Creating user-defined volumes... job=209 project=5 runner=CxMj2wKw
Using host-based "/var/run/docker.sock" for "/var/run/docker.sock"... job=209 project=5 runner=CxMj2wKw
Cache containers feature is disabled job=209 project=5 runner=CxMj2wKw
WARNING: Container based cache volumes creation is disabled. Will not create volume for "/cache" job=209 project=5 runner=CxMj2wKw
Creating build volume... job=209 project=5 runner=CxMj2wKw
Cache containers feature is disabled job=209 project=5 runner=CxMj2wKw
Feeding runners to channel builds=1
Created container to set volume permissions container_id=81b3c9b02979bc0779d6cf188f454a01b7716df50a890d9002c78818a30d0019 context=set_volume_permission job=209 project=5 runner=CxMj2wKw volume_name=runner-cxmj2wkw-project-5-concurrent-0-cache-c33bcaa1fd2c77edfc3893b41966cea8
Appending trace to coordinator... ok code=202 job=209 job-log=0-359 job-status=running runner=CxMj2wKw sent-log=0-358 status=202 Accepted update-interval=3s
Updated volume permissions container_id=81b3c9b02979bc0779d6cf188f454a01b7716df50a890d9002c78818a30d0019 context=set_volume_permission job=209 project=5 runner=CxMj2wKw volume_name=runner-cxmj2wkw-project-5-concurrent-0-cache-c33bcaa1fd2c77edfc3893b41966cea8
Using host-based "runner-cxmj2wkw-project-5-concurrent-0-cache-c33bcaa1fd2c77edfc3893b41966cea8" for "/builds"... job=209 project=5 runner=CxMj2wKw
Using volume "runner-cxmj2wkw-project-5-concurrent-0-cache-c33bcaa1fd2c77edfc3893b41966cea8" as cache "/builds"... job=209 project=5 runner=CxMj2wKw
Creating services... job=209 project=5 runner=CxMj2wKw
Building service links... job=209 project=5 runner=CxMj2wKw
Starting Docker command... job=209 project=5 runner=CxMj2wKw
Looking for prebuilt image gitlab/gitlab-runner-helper:x86_64-21cb397c... job=209 project=5 runner=CxMj2wKw
No credentials found for docker.io job=209 project=5 runner=CxMj2wKw
Looking for image docker:stable ... job=209 project=5 runner=CxMj2wKw
Pulling docker image docker:stable ... job=209 project=5 runner=CxMj2wKw
Appending trace to coordinator... ok code=202 job=209 job-log=0-407 job-status=running runner=CxMj2wKw sent-log=359-406 status=202 Accepted update-interval=3s
Submitting job to coordinator... ok code=200 job=209 job-status= runner=CxMj2wKw
Submitting job to coordinator... ok code=200 job=209 job-status= runner=CxMj2wKw
Submitting job to coordinator... ok code=200 job=209 job-status= runner=CxMj2wKw
Submitting job to coordinator... ok code=200 job=209 job-status= runner=CxMj2wKw
Submitting job to coordinator... ok code=200 job=209 job-status= runner=CxMj2wKw
Using docker image sha256:0bfe00e7bcd536451161fd64b2fe05f4ff6373ce9dd241e9762b68c7f56ce438 for docker:stable ... job=209 project=5 runner=CxMj2wKw
Waiting for signals... job=209 project=5 runner=CxMj2wKw
No referees configured job=209 project=5 runner=CxMj2wKw
Executing build stage build_stage=prepare_script job=209 project=5 runner=CxMj2wKw
Preparing environment job=209 project=5 runner=CxMj2wKw
Looking for prebuilt image gitlab/gitlab-runner-helper:x86_64-21cb397c... job=209 project=5 runner=CxMj2wKw
No credentials found for docker.io job=209 project=5 runner=CxMj2wKw
Looking for image sha256:4c954aab5d9b345309a350250fc6c023f62305cf97a9866800ef9951000de981 ... job=209 project=5 runner=CxMj2wKw
Removing container runner-cxmj2wkw-project-5-concurrent-0-052b74032c9fc8fb-predefined-0 job=209 project=5 runner=CxMj2wKw
Disconnecting container runner-cxmj2wkw-project-5-concurrent-0-052b74032c9fc8fb-predefined-0 from networks job=209 project=5 runner=CxMj2wKw
Removing container runner-cxmj2wkw-project-5-concurrent-0-052b74032c9fc8fb-predefined-0 finished with error Error: No such container: runner-cxmj2wkw-project-5-concurrent-0-052b74032c9fc8fb-predefined-0 (docker.go:902:0s) job=209 project=5 runner=CxMj2wKw
Creating container runner-cxmj2wkw-project-5-concurrent-0-052b74032c9fc8fb-predefined-0 ... job=209 project=5 runner=CxMj2wKw
Appending trace to coordinator... ok code=202 job=209 job-log=0-660 job-status=running runner=CxMj2wKw sent-log=407-659 status=202 Accepted update-interval=3s
Executing on /runner-cxmj2wkw-project-5-concurrent-0-052b74032c9fc8fb-predefined-0 the #!/usr/bin/env bash
set -eo pipefail
set +o noclobber
: | eval $'echo "Running on $(hostname) via hduser-HP-Z820-Workstation..."\n'
exit 0
job=209 project=5 runner=CxMj2wKw
Attaching to container a7d3a2d255df00a4bd2e64d361e0edb69c100e47405049de1f9d99cfe108fa18 ... job=209 project=5 runner=CxMj2wKw
Starting container a7d3a2d255df00a4bd2e64d361e0edb69c100e47405049de1f9d99cfe108fa18 ... job=209 project=5 runner=CxMj2wKw
Waiting for attach to finish a7d3a2d255df00a4bd2e64d361e0edb69c100e47405049de1f9d99cfe108fa18 ... job=209 project=5 runner=CxMj2wKw
Waiting for container a7d3a2d255df00a4bd2e64d361e0edb69c100e47405049de1f9d99cfe108fa18 ... job=209 project=5 runner=CxMj2wKw
Container a7d3a2d255df00a4bd2e64d361e0edb69c100e47405049de1f9d99cfe108fa18 finished with <nil> job=209 project=5 runner=CxMj2wKw
Executing build stage build_stage=get_sources job=209 project=5 runner=CxMj2wKw
panic: runtime error: index out of range [1] with length 1
goroutine 89 [running]:
gitlab.com/gitlab-org/gitlab-runner/common.(*Build).GetRemoteURL(0xc00055f880, 0x1a7ad20, 0xc00053e640)
/builds/gitlab-org/gitlab-runner/common/build.go:814 +0x3b0
gitlab.com/gitlab-org/gitlab-runner/shells.(*AbstractShell).writeRefspecFetchCmd(0xc00017e430, 0x1a7ad20, 0xc00053e640, 0xc00055f880, 0xc000670780, 0x16, 0xc000473040, 0x1b)
/builds/gitlab-org/gitlab-runner/shells/abstract.go:311 +0x39a
gitlab.com/gitlab-org/gitlab-runner/shells.(*AbstractShell).handleGetSourcesStrategy(0xc00017e430, 0x1a7ad20, 0xc00053e640, 0xc00055f880, 0x1, 0x0)
/builds/gitlab-org/gitlab-runner/shells/abstract.go:274 +0x2c1
gitlab.com/gitlab-org/gitlab-runner/shells.(*AbstractShell).writeCloneFetchCmds(0xc00017e430, 0x1a7ad20, 0xc00053e640, 0x17c45cf, 0x4, 0xc00055f880, 0x0, 0x0, 0x0, 0x17e846d, ...)
/builds/gitlab-org/gitlab-runner/shells/abstract.go:235 +0x6b
gitlab.com/gitlab-org/gitlab-runner/shells.(*AbstractShell).writeGetSourcesScript(0xc00017e430, 0x1a7ad20, 0xc00053e640, 0x17c45cf, 0x4, 0xc00055f880, 0x0, 0x0, 0x0, 0x17e846d, ...)
/builds/gitlab-org/gitlab-runner/shells/abstract.go:181 +0xf3
gitlab.com/gitlab-org/gitlab-runner/shells.(*AbstractShell).writeScript(0xc00017e430, 0x1a7ad20, 0xc00053e640, 0x17cdc2c, 0xb, 0x17c45cf, 0x4, 0xc00055f880, 0x0, 0x0, ...)
/builds/gitlab-org/gitlab-runner/shells/abstract.go:658 +0x6eb
gitlab.com/gitlab-org/gitlab-runner/shells.(*BashShell).generateScript(0xc00017e430, 0x1a7ad20, 0xc00053e640, 0x17cdc2c, 0xb, 0x17c45cf, 0x4, 0xc00055f880, 0x0, 0x0, ...)
/builds/gitlab-org/gitlab-runner/shells/bash.go:269 +0xfb
gitlab.com/gitlab-org/gitlab-runner/shells.(*BashShell).GenerateScript(0xc00017e430, 0x17cdc2c, 0xb, 0x17c45cf, 0x4, 0xc00055f880, 0x0, 0x0, 0x0, 0x17e846d, ...)
/builds/gitlab-org/gitlab-runner/shells/bash.go:264 +0x188
gitlab.com/gitlab-org/gitlab-runner/common.GenerateShellScript(0x17cdc2c, 0xb, 0x17c45cf, 0x4, 0xc00055f880, 0x0, 0x0, 0x0, 0x17e846d, 0x1d, ...)
/builds/gitlab-org/gitlab-runner/common/shell.go:102 +0x9e
gitlab.com/gitlab-org/gitlab-runner/common.(*Build).executeStage(0xc00055f880, 0x1a42ec0, 0xc0003a47c0, 0x17cdc2c, 0xb, 0x1a55f00, 0xc000612000, 0x0, 0x1a05700)
/builds/gitlab-org/gitlab-runner/common/build.go:256 +0x256
gitlab.com/gitlab-org/gitlab-runner/common.(*Build).attemptExecuteStage(0xc00055f880, 0x1a42ec0, 0xc0003a47c0, 0x17cdc2c, 0xb, 0x1a55f00, 0xc000612000, 0x1, 0x0, 0x259b1c0)
/builds/gitlab-org/gitlab-runner/common/build.go:410 +0xc5
gitlab.com/gitlab-org/gitlab-runner/common.(*Build).executeScript(0xc00055f880, 0x1a42ec0, 0xc0003a47c0, 0x1a55f00, 0xc000612000, 0x0, 0x0)
/builds/gitlab-org/gitlab-runner/common/build.go:328 +0x5a8
gitlab.com/gitlab-org/gitlab-runner/common.(*Build).run.func1(0xc00038f500, 0xc00055f880, 0x1a42ec0, 0xc0003a47c0, 0x1a55f00, 0xc000612000)
/builds/gitlab-org/gitlab-runner/common/build.go:462 +0x56
created by gitlab.com/gitlab-org/gitlab-runner/common.(*Build).run
/builds/gitlab-org/gitlab-runner/common/build.go:461 +0x214
the related gitlab-runner configuration is
gitlab-runner config
concurrent = 1
check_interval = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "ci-runner"
output_limit=409600
url = "https://192.168.0.60/"
token = "s2cNzs5hCE3diWmAQ85C"
tls-ca-file = "/etc/gitlab-runner/my-root.crt"
executor = "docker"
clone_url="https://192.168.0.60/"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.docker]
tls_verify = false
image = "alpine"
privileged = true
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = true
volumes = ["/cache"]
shm_size = 0
[[runners]]
name = "docker-socket"
url = "https://192.168.0.60/"
token = "CxMj2wKwpMa8okrZA4dx"
tls-ca-file = "/etc/gitlab-runner/my-root.crt"
executor = "docker"
clone_url="https:/192.168.0.60/"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
ServerAddress = "192.168.0.60:9005"
AccessKey = "minio"
SecretKey = "minio123"
BucketName = "gitlab-runner"
Insecure = true
[runners.cache.gcs]
[runners.docker]
tls_verify = false
image = "alpine"
privileged = true
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = true
volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
shm_size = 0