Skip to content

Commit

Permalink
Correct cleanup gitlab-ci
Browse files Browse the repository at this point in the history
Found the issue on regular testing hosts:
  https://gitlab.com/tarantool/tarantool/-/jobs/577884238

  Fetching changes...
  00:04
   Reinitialized existing Git repository in
     /home/gitlab-runner/builds/zzyC6hh5/0/tarantool/tarantool/.git/
   Checking out 8ff7f32 as ...
   warning: failed to remove CMakeFiles/Makefile.cmake

Found the job that saved the directories with root permissions
https://gitlab.com/tarantool/tarantool/-/jobs/577768553

The issue appeared because the issue caused job used the script
runner to run docker in it as additional command. It caused the
the gitlab-runner default workspace cleanup to be outside the
docker (in opposite to the jobs when docker runner used, the
cleanup runs inside the docker and no fails exists ever).
Cleanup failed to remove files created by root inside the docker
container before and which were shared to global host.

To fix the issue need to run docker images using the gitlab-runner
only in RO mode with Out-Of-Source builds in it. Either use the
docker runners when docker containers are needed. Anyway script
runner jobs with additional calls to dockers can't be control for
the branches of developers, to avoid of it need to make local
cleanup instead of default to the working paths for each job with
script runners use.

Decided to setup gitlab-runner configuration as described in:
https://docs.gitlab.com/ce/ci/yaml/README.html#git-clean-flags

Closes #5036
  • Loading branch information
avtikhon committed Jun 3, 2020
1 parent a70675e commit d6b7eba
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .gitlab-ci.yml
Expand Up @@ -6,6 +6,14 @@ stages:
variables:
GITLAB_MAKE: "make -f .gitlab.mk"

.shell_cleanup_variables_template:
variables: &shell_cleanup_variable
GIT_CLEAN_FLAGS: none

.shell_before_script_template: &shell_cleanup_script
before_script:
- docker run -w /source -v ${PWD}:/source -i packpack/packpack:el-7 git clean -ffdx

# Jobs templates

.release_only_template: &release_only_definition
Expand Down Expand Up @@ -55,6 +63,7 @@ variables:
stage: test
tags:
- deploy
<<: *shell_cleanup_script
script:
- ${GITLAB_MAKE} package

Expand All @@ -63,6 +72,7 @@ variables:
stage: test
tags:
- deploy_test
<<: *shell_cleanup_script
script:
- ${GITLAB_MAKE} package

Expand All @@ -71,6 +81,7 @@ variables:
stage: test
tags:
- deploy
<<: *shell_cleanup_script
script:
- ${GITLAB_MAKE} deploy

Expand All @@ -79,6 +90,7 @@ variables:
stage: test
tags:
- deploy_test
<<: *shell_cleanup_script
script:
- ${GITLAB_MAKE} deploy

Expand Down Expand Up @@ -155,13 +167,19 @@ osx_14_release:
stage: test
tags:
- osx_14
variables:
<<: *shell_cleanup_variable
<<: *shell_cleanup_script
script:
- ${GITLAB_MAKE} test_osx

osx_15_release:
stage: test
tags:
- osx_15
variables:
<<: *shell_cleanup_variable
<<: *shell_cleanup_script
script:
- ${GITLAB_MAKE} test_osx

Expand All @@ -172,6 +190,8 @@ osx_15_release_lto:
- osx_15
variables:
EXTRA_ENV: 'export CMAKE_EXTRA_PARAMS=-DENABLE_LTO=ON ;'
<<: *shell_cleanup_variable
<<: *shell_cleanup_script
script:
- ${GITLAB_MAKE} test_osx

Expand All @@ -184,6 +204,8 @@ freebsd_12_release:
VMS_USER: 'vagrant'
VMS_PORT: '2232'
MAKE: 'gmake'
<<: *shell_cleanup_variable
<<: *shell_cleanup_script
script:
- ${GITLAB_MAKE} vms_test_freebsd

Expand Down Expand Up @@ -299,6 +321,9 @@ remove_images_sh9:

sources:
<<: *pack_definition
variables:
<<: *shell_cleanup_variable
<<: *shell_cleanup_script
script:
- ${GITLAB_MAKE} source

Expand All @@ -307,95 +332,113 @@ centos_6:
variables:
OS: 'el'
DIST: '6'
<<: *shell_cleanup_variable

centos_7:
<<: *pack_test_definition
variables:
OS: 'el'
DIST: '7'
<<: *shell_cleanup_variable

centos_8:
<<: *pack_test_definition
variables:
OS: 'el'
DIST: '8'
<<: *shell_cleanup_variable

fedora_28:
<<: *pack_test_definition
variables:
OS: 'fedora'
DIST: '28'
<<: *shell_cleanup_variable

fedora_29:
<<: *pack_test_definition
variables:
OS: 'fedora'
DIST: '29'
<<: *shell_cleanup_variable

fedora_30:
<<: *pack_test_definition
variables:
OS: 'fedora'
DIST: '30'
<<: *shell_cleanup_variable

fedora_31:
<<: *pack_test_definition
variables:
OS: 'fedora'
DIST: '31'
<<: *shell_cleanup_variable

ubuntu_14_04:
<<: *pack_definition
variables:
OS: 'ubuntu'
DIST: 'trusty'
<<: *shell_cleanup_variable

ubuntu_16_04:
<<: *pack_definition
variables:
OS: 'ubuntu'
DIST: 'xenial'
<<: *shell_cleanup_variable

ubuntu_18_04:
<<: *pack_definition
variables:
OS: 'ubuntu'
DIST: 'bionic'
<<: *shell_cleanup_variable

ubuntu_19_10:
<<: *pack_definition
variables:
OS: 'ubuntu'
DIST: 'eoan'
<<: *shell_cleanup_variable

ubuntu_20_04:
<<: *pack_definition
variables:
OS: 'ubuntu'
DIST: 'focal'
<<: *shell_cleanup_variable

debian_8:
<<: *pack_definition
variables:
OS: 'debian'
DIST: 'jessie'
<<: *shell_cleanup_variable

debian_9:
<<: *pack_definition
variables:
OS: 'debian'
DIST: 'stretch'
<<: *shell_cleanup_variable

debian_10:
<<: *pack_definition
variables:
OS: 'debian'
DIST: 'buster'
<<: *shell_cleanup_variable

# Deploy

sources_deploy:
<<: *deploy_definition
variables:
<<: *shell_cleanup_variable
<<: *shell_cleanup_script
script:
- ${GITLAB_MAKE} source_deploy

Expand All @@ -404,95 +447,113 @@ centos_6_deploy:
variables:
OS: 'el'
DIST: '6'
<<: *shell_cleanup_variable

centos_7_deploy:
<<: *deploy_test_definition
variables:
OS: 'el'
DIST: '7'
<<: *shell_cleanup_variable

centos_8_deploy:
<<: *deploy_test_definition
variables:
OS: 'el'
DIST: '8'
<<: *shell_cleanup_variable

fedora_28_deploy:
<<: *deploy_test_definition
variables:
OS: 'fedora'
DIST: '28'
<<: *shell_cleanup_variable

fedora_29_deploy:
<<: *deploy_test_definition
variables:
OS: 'fedora'
DIST: '29'
<<: *shell_cleanup_variable

fedora_30_deploy:
<<: *deploy_test_definition
variables:
OS: 'fedora'
DIST: '30'
<<: *shell_cleanup_variable

fedora_31_deploy:
<<: *deploy_test_definition
variables:
OS: 'fedora'
DIST: '31'
<<: *shell_cleanup_variable

ubuntu_14_04_deploy:
<<: *deploy_definition
variables:
OS: 'ubuntu'
DIST: 'trusty'
<<: *shell_cleanup_variable

ubuntu_16_04_deploy:
<<: *deploy_definition
variables:
OS: 'ubuntu'
DIST: 'xenial'
<<: *shell_cleanup_variable

ubuntu_18_04_deploy:
<<: *deploy_definition
variables:
OS: 'ubuntu'
DIST: 'bionic'
<<: *shell_cleanup_variable

ubuntu_19_10_deploy:
<<: *deploy_definition
variables:
OS: 'ubuntu'
DIST: 'eoan'
<<: *shell_cleanup_variable

ubuntu_20_04_deploy:
<<: *deploy_definition
variables:
OS: 'ubuntu'
DIST: 'focal'
<<: *shell_cleanup_variable

debian_8_deploy:
<<: *deploy_definition
variables:
OS: 'debian'
DIST: 'jessie'
<<: *shell_cleanup_variable

debian_9_deploy:
<<: *deploy_definition
variables:
OS: 'debian'
DIST: 'stretch'
<<: *shell_cleanup_variable

debian_10_deploy:
<<: *deploy_definition
variables:
OS: 'debian'
DIST: 'buster'
<<: *shell_cleanup_variable

# Static builds

static_build:
<<: *docker_test_definition
variables:
<<: *shell_cleanup_variable
<<: *shell_cleanup_script
script:
- ${GITLAB_MAKE} test_static_build

Expand All @@ -501,5 +562,8 @@ static_docker_build:
stage: test
tags:
- deploy_test
variables:
<<: *shell_cleanup_variable
<<: *shell_cleanup_script
script:
- ${GITLAB_MAKE} test_static_docker_build

0 comments on commit d6b7eba

Please sign in to comment.