Pipeline not start service
Summary
There is a problem in Pipelines with services. I configure a mysql service but the service don't go up and then my test fail. This don't happen all the times but is very frequent.
Steps to reproduce
There is no way to accurately reproduce the problem, but I attached a log where the .gitlab-ci is shown
Running with gitlab-runner 11.10.1 (1f513601)
on gitlab-runner-gitlab-runner-787896b74d-7zlzs xwUAwtgT
Using Kubernetes namespace: gitlab-runners
Using Kubernetes executor with image node:lts-alpine ...
Waiting for pod gitlab-runners/runner-xwuawtgt-project-12346619-concurrent-2t99ms to be running, status is Pending
Waiting for pod gitlab-runners/runner-xwuawtgt-project-12346619-concurrent-2t99ms to be running, status is Pending
Waiting for pod gitlab-runners/runner-xwuawtgt-project-12346619-concurrent-2t99ms to be running, status is Pending
Running on runner-xwuawtgt-project-12346619-concurrent-2t99ms via gitlab-runner-gitlab-runner-787896b74d-7zlzs...
Initialized empty Git repository in /builds/....../service/.git/
Fetching changes...
Created fresh repository.
From https://gitlab.com/cencosud-ds/venta/paris-peru/orders-service
* [new branch] 1-deploy-to-test-env -> origin/1-deploy-to-test-env
* [new branch] master -> origin/master
Checking out 08f29324 as 1-deploy-to-test-env...
Skipping Git submodules setup
Checking cache for default...
No URL provided, cache will not be downloaded from shared cache server. Instead a local version of cache will be extracted.
Successfully extracted cache
$ apk update && apk add mysql-client
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
v3.9.4-24-g4e2ff29bbe [http://dl-cdn.alpinelinux.org/alpine/v3.9/main]
v3.9.4-26-ga3169d5242 [http://dl-cdn.alpinelinux.org/alpine/v3.9/community]
OK: 9770 distinct packages available
(1/6) Installing mariadb-common (10.3.15-r0)
(2/6) Installing ncurses-terminfo-base (6.1_p20190105-r0)
(3/6) Installing ncurses-terminfo (6.1_p20190105-r0)
(4/6) Installing ncurses-libs (6.1_p20190105-r0)
(5/6) Installing mariadb-client (10.3.15-r0)
(6/6) Installing mysql-client (10.3.15-r0)
Executing busybox-1.29.3-r10.trigger
OK: 45 MiB in 22 packages
$ cat .gitlab-ci.yml
# This file is a template, and might need editing before it works on your project.
# Official framework image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/node/tags/
image: node:lts-alpine
# This folder is cached between builds
# http://docs.gitlab.com/ce/ci/yaml/README.html#cache
cache:
paths:
- node_modules/
stages:
- install
- test
- build
install:
stage: install
script:
- npm install
lint:
stage: test
script:
- npm install
- npm run lint
unit-test:
stage: test
script:
- npm install
- npm run test
e2e-test:
stage: test
variables:
MYSQL_ROOT_PASSWORD: '${MYSQL_ROOT_PASSWORD}'
MYSQL_DATABASE: '${MYSQL_DATABASE}'
before_script:
- apk update && apk add mysql-client
- cat .gitlab-ci.yml
script:
- npm install
- npm run test:e2e
- mysqldump -u ${TYPEORM_USERNAME} -p${TYPEORM_PASSWORD} --no-data -h ${TYPEORM_HOST} ${TYPEORM_DATABASE}
services:
- name: mysql:latest
command: ['--default-authentication-plugin=mysql_native_password']
build:
image: docker:git
stage: build
services:
- docker:dind
before_script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com
only:
- branches
script:
- export TAG="$CI_COMMIT_REF_NAME-$CI_PIPELINE_IID-$CI_COMMIT_SHORT_SHA"
- export IMAGE="$CI_REGISTRY_IMAGE:$TAG"
- echo $IMAGE
- docker build --no-cache -t $IMAGE .
$ npm install
> @nestjs/core@6.2.0 postinstall /builds/cencosud-ds/venta/paris-peru/orders-service/node_modules/@nestjs/core
> opencollective || exit 0
Thanks for installing nest
Please consider donating to our open collective
to help us maintain this package.
Number of contributors: 91
Number of backers: 189
Annual budget: $67,937
Current balance: $5,604
Become a partner: https://opencollective.com/nest/donate
> nodemon@1.19.0 postinstall /builds/cencosud-ds/venta/paris-peru/orders-service/node_modules/nodemon
> node bin/postinstall || exit 0
Love nodemon? You can now support the project via the open collective:
> https://opencollective.com/nodemon/donate
npm WARN orders-service@0.0.1 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
added 886 packages from 886 contributors and audited 864219 packages in 19.03s
found 1 moderate severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details
$ npm run test:e2e
> orders-service@0.0.1 test:e2e /builds/cencosud-ds/venta/paris-peru/orders-service
> jest --config ./test/jest-e2e.json
[Nest] 66 - 06/11/2019, 11:37 AM [ExceptionHandler] Unable to connect to the database. Retrying (1)...
Error: getaddrinfo ENOTFOUND mysql mysql:3306
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)