Closed chinleung closed 6 years ago
@chinleung what versions of gitlab, docker and gitlab-runner are you using? After which command the error is displayed? It seems like some problem with underlying docker, cause it means that testing image could not connect to mysql docker instance. Is mysql properly downloaded and started in gitlab pipeline logs?
@chilio In the GitLab admin, it says the runner is on version 10.4.0 but when I execute gitlab-runner --version
on the server, I get the following:
Version: 11.0.0
Git revision: 5396d320
Git branch: 11-0-stable
GO version: go1.8.7
Built: 2018-06-22T11:03:37+00:00
OS/Arch: linux/amd64
I see the following in the logs during both the build and the test stage:
Using Docker executor with image chilio/laravel-dusk-ci:stable ...
Starting service mysql:5.7 ...
Pulling docker image mysql:5.7 ...
Using docker image mysql:5.7 ID=sha256:66bc0f66b7af6ba3ea96582685d3afcd6dff93c2f8999da0ffadd67b280db548 for mysql service...
Waiting for services to be up and running...
*** WARNING: Service runner-689f83b9-project-23-concurrent-0-mysql-0 probably didn't start properly.
I'm not too familiar with Docker. Do you have any idea how to fix this?
@chinleung Your problem is in this line:
*** WARNING: Service runner-689f83b9-project-23-concurrent-0-mysql-0 probably didn't start properly.
Which means that docker has problem running mysql instance.
Therefore throwed error: SQLSTATE[HY000] [2002] php_network_getaddresses:
makes sense.
There could be several problems, but for sure you need to check your docker installation (sometimes it can be something as silly as low space, mem, etc.)
First I would try to run mysql manually and make sure it works... Some more info here...
@chilio Yeah that's what I thought too. Thanks I'll have a look on why it's not starting properly. I'll post back here once I find the solution for anyone with the same issue.
@chinleung did you succeeded with this issue?
@chilio No I am still working on it. I've tried multiple things like these guides:
I've also tried to enable the privileged
to the docker container but I'm still unable to start the SQL service.
Using Docker executor with image chilio/laravel-dusk-ci:stable ...
Starting service mysql:5.7 ...
Pulling docker image mysql:5.7 ...
Using docker image sha256:66bc0f66b7af6ba3ea96582685d3afcd6dff93c2f8999da0ffadd67b280db548 for mysql:5.7 ...
Waiting for services to be up and running...
*** WARNING: Service runner-237f18d2-project-23-concurrent-0-mysql-0 probably didn't start properly.
Health check error:
ContainerStart: Error response from daemon: Cannot link to a non running container: /runner-237f18d2-project-23-concurrent-0-mysql-0 AS /runner-237f18d2-project-23-concurrent-0-mysql-0-wait-for-service/service
Service container logs:
2018-07-11T19:49:03.214991318Z
2018-07-11T19:49:03.215062485Z ERROR: mysqld failed while attempting to check config
2018-07-11T19:49:03.215067480Z command was: "mysqld --verbose --help"
2018-07-11T19:49:03.215070774Z
2018-07-11T19:49:03.215073778Z mysqld: error while loading shared libraries: libpthread.so.0: cannot stat shared object: Permission denied
@chinleung My advice is you should not dig dipper, with gitlab....
I believe this is a problem with your underlying infrastructure (probably docker).
I have experienced this error only once, and it was when my test system was overloaded...
So please make sure you can run docker mysql instance without any issues....
@chilio I think that's the issue, I'm not able to run mysql properly with docker but I can't figure out why... Any ideas?
@chinleung I would try to reinstall docker on your system, have you tried that? And check if you don't have mysql installed on your host system. Here is more info
@chilio Oh wait, I can't have MySQL on my host machine?
@chinleung I've never tried it, but I have seen that others had some problems with that... Please check this issue also...
@chinleung By using services: -mysql:5.7
. This kind of structure is automatically created
So everything is a docker container and you don't have to manage your mysql VM/container or even the service on your host by yourself.
By using
variables:
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: root
MYSQL_PASSWORD: secret
MYSQL_DATABASE: test
DB_HOST: mysql
DB_CONNECTION: mysql
The database is already created with the credentials and @chilio made a little script to make your life easier by using
script:
- configure-laravel
Your laravel env will be setup and your database will be created and seeded (Idon't know if this word exist)
You can have a look here to see what this command is really doing.
I hope it will help you to debug or at least to have a better understanding of the workflow.
@chinleung any updates on this?
Oh sorry I didn't see @Raccoon5031 's message. So basically it won't work if I have MySQL on my main host. The thing is, I'm using the main host to serve websites, therefore I need the MySQL service running.
@chilio It's not really a fix to the issue, but I realized, I don't even need to install MySQL in my docker because I don't use it all during the tests.
@chinleung if so you can modify .gitlab-ci.yml to use alias for example:
services:
- name: mysql:5.7
alias: mysql-test
and then in variables section:
variables:
...
DB_HOST: mysql-test
This should work without a problem. Please check and let me know if it works....
I simply removed the mysql from the services completely and it's working. 👍
@chinleung I know, but could you check this solution? So you can have it working where you will use mysql in tests also?
@chilio Okay sure, I'll test it and get back to you in like ±3 hours. I don't have access to my laptop right now. Do you want me to add the alias to both stages?
@chinleung yes please do, everywhere where you reference mysql in services:
...
@chilio Yes adding an alias seems to be working!
@chinleung I'm glad to hear that...
@chilio received same error today on the shared runner. Maybe alias
for MySQL service should be set by default in example .gitlab-ci.yml
file?
@scofield-ua thanks for the tip.
Readme and .gitlab-ci.yml
updated...
I've taken the files from the example and it keeps giving me this:
Here's the .gitlab-ci
And my .env.example: