CI Runner Healthcheck doesnt recognize open port
I've the following CI config on my local CE 11.11.3, Runner 11.11.2:
stages:
- run_jobs
variables:
MYSQL_DATABASE: your_db_name
MYSQL_ROOT_PASSWORD: mysql
test_service:
stage: run_jobs
image: alpine:latest
services:
- mariadb
script:
- apk --no-cache add mysql-client
- mysql --version
- sleep 10
- echo "SHOW tables;"| mysql -u root -p"$MYSQL_ROOT_PASSWORD" -h mariadb "${MYSQL_DATABASE}"
It should start a MariaDB service and just connects to it. But I got always this warning and the connect doesn't work. The same with mysql or other versions of MariaDB.
Running with gitlab-runner 11.11.2 (ac2a293c)
on 3889d5e6a75e PyK5_zUy
Using Docker executor with image alpine:latest ...
Starting service mariadb:latest ...
Pulling docker image mariadb:latest ...
Using docker image sha256:f1e4084965e5ec0ad678aca1b1d790fec14f831864c1e63a34aaddf43b793232 for mariadb:latest ...
Waiting for services to be up and running...
*** WARNING: Service runner-PyK5_zUy-project-2-concurrent-0-mariadb-0 probably didn't start properly.
Health check error:
service "runner-PyK5_zUy-project-2-concurrent-0-mariadb-0-wait-for-service" timeout
Health check container logs:
....
2019-06-25T14:51:45.993759123Z 2019-06-25 14:51:45 0 [Note] mysqld: ready for connections.
2019-06-25T14:51:45.993761286Z Version: '10.4.6-MariaDB-1:10.4.6+maria~bionic' socket: '/var/run/mysqld/mysqld.sock' port: 0 mariadb.org binary distribution
...
$ mysql --version
mysql Ver 15.1 Distrib 10.3.16-MariaDB, for Linux (x86_64) using readline 5.1
$ sleep 10
$ echo "SHOW tables;"| mysql -u root -p"$MYSQL_ROOT_PASSWORD" -h mariadb "${MYSQL_DATABASE}"
ERROR 2002 (HY000): Can't connect to MySQL server on 'mariadb' (115)
ERROR: Job failed: exit code 1
I read about how the health check works and I can see via docker ps
on the machine a new docker instance of mariadb listining on 3306/tcp
. So the service is ready - the log message says it to, everything works, but the Gitlab Runner neither recognizes the running and open MariaDB port.
#> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c3b11fb5cb2d 1b0e92b652c1 "gitlab-runner-helpe…" 28 seconds ago Up 26 seconds runner-PyK5_zUy-project-2-concurrent-0-mariadb-0-wait-for-service
75852e70a264 f1e4084965e5 "docker-entrypoint.s…" 29 seconds ago Up 27 seconds 3306/tcp runner-PyK5_zUy-project-2-concurrent-0-mariadb-0
bc995cde3491 gitlab/gitlab-runner:latest "/usr/bin/dumb-init …" 16 minutes ago Up 16 minutes gitlab-runner_runner_1
So, what is the problem? Logs are good, Services are running, but Healthcheck or the CI can reach it.