Fix reports jobs timing out because of cache
Note: This commit relies on https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/26801 which brings support to multiple extends. While `cache: {}` can disable a cache being set globally, it doesn't work with extends, which will perform a reverse deep merge based on the keys. The cache defined in the base `.default-cache` job won't be disabled in the report jobs. As a side effect, the `code_quality`, `sast`, and `dependency_scanning` jobs are running on a larger code base than expected, leading to timeouts. fixes https://gitlab.com/gitlab-org/gitlab-ee/issues/11303 fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/60879 fixes https://gitlab.com/gitlab-org/gitlab-ee/issues/12021
This commit is contained in:
parent
3115c9fc12
commit
ab696cdf28
3 changed files with 25 additions and 82 deletions
|
@ -28,11 +28,15 @@
|
||||||
policy: pull
|
policy: pull
|
||||||
stage: test
|
stage: test
|
||||||
|
|
||||||
.dedicated-no-docs-pull-cache-job:
|
.no-docs:
|
||||||
extends: .dedicated-pull-cache-job
|
|
||||||
except:
|
except:
|
||||||
- /(^docs[\/-].*|.*-docs$)/
|
- /(^docs[\/-].*|.*-docs$)/
|
||||||
|
|
||||||
|
.dedicated-no-docs-pull-cache-job:
|
||||||
|
extends:
|
||||||
|
- .dedicated-pull-cache-job
|
||||||
|
- .no-docs
|
||||||
|
|
||||||
.dedicated-no-docs-and-no-qa-pull-cache-job:
|
.dedicated-no-docs-and-no-qa-pull-cache-job:
|
||||||
extends: .dedicated-pull-cache-job
|
extends: .dedicated-pull-cache-job
|
||||||
except:
|
except:
|
||||||
|
@ -45,6 +49,12 @@
|
||||||
variables:
|
variables:
|
||||||
SETUP_DB: "false"
|
SETUP_DB: "false"
|
||||||
|
|
||||||
|
# Jobs that need a dedicated runner, with no cache
|
||||||
|
.dedicated-no-docs:
|
||||||
|
extends:
|
||||||
|
- .dedicated-runner
|
||||||
|
- .no-docs
|
||||||
|
|
||||||
.single-script-job-dedicated-runner:
|
.single-script-job-dedicated-runner:
|
||||||
extends: .dedicated-runner
|
extends: .dedicated-runner
|
||||||
image: ruby:2.6-alpine
|
image: ruby:2.6-alpine
|
||||||
|
|
|
@ -1,98 +1,26 @@
|
||||||
include:
|
include:
|
||||||
- template: Code-Quality.gitlab-ci.yml
|
- template: Code-Quality.gitlab-ci.yml
|
||||||
|
- template: Security/SAST.gitlab-ci.yml
|
||||||
|
- template: Security/Dependency-Scanning.gitlab-ci.yml
|
||||||
|
|
||||||
code_quality:
|
code_quality:
|
||||||
extends: .dedicated-no-docs-no-db-pull-cache-job
|
extends: .dedicated-no-docs
|
||||||
# gitlab-org runners set `privileged: false` but we need to have it set to true
|
# gitlab-org runners set `privileged: false` but we need to have it set to true
|
||||||
# since we're using Docker in Docker
|
# since we're using Docker in Docker
|
||||||
tags: []
|
tags: []
|
||||||
before_script: []
|
before_script: []
|
||||||
cache: {}
|
cache: {}
|
||||||
dependencies: []
|
dependencies: []
|
||||||
variables:
|
|
||||||
SETUP_DB: "false"
|
|
||||||
|
|
||||||
sast:
|
sast:
|
||||||
extends: .dedicated-no-docs-no-db-pull-cache-job
|
extends: .dedicated-no-docs
|
||||||
image: docker:stable
|
before_script: []
|
||||||
|
tags: []
|
||||||
variables:
|
variables:
|
||||||
SAST_CONFIDENCE_LEVEL: 2
|
SAST_CONFIDENCE_LEVEL: 2
|
||||||
DOCKER_DRIVER: overlay2
|
DOCKER_DRIVER: overlay2
|
||||||
allow_failure: true
|
|
||||||
tags: []
|
|
||||||
before_script: []
|
|
||||||
cache: {}
|
|
||||||
dependencies: []
|
|
||||||
services:
|
|
||||||
- docker:stable-dind
|
|
||||||
script:
|
|
||||||
- | # this is required to avoid undesirable reset of Docker image ENV variables being set on build stage
|
|
||||||
function propagate_env_vars() {
|
|
||||||
CURRENT_ENV=$(printenv)
|
|
||||||
|
|
||||||
for VAR_NAME; do
|
|
||||||
echo $CURRENT_ENV | grep "${VAR_NAME}=" > /dev/null && echo "--env $VAR_NAME "
|
|
||||||
done
|
|
||||||
}
|
|
||||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
|
||||||
- |
|
|
||||||
docker run \
|
|
||||||
$(propagate_env_vars \
|
|
||||||
SAST_ANALYZER_IMAGES \
|
|
||||||
SAST_ANALYZER_IMAGE_PREFIX \
|
|
||||||
SAST_ANALYZER_IMAGE_TAG \
|
|
||||||
SAST_DEFAULT_ANALYZERS \
|
|
||||||
SAST_BRAKEMAN_LEVEL \
|
|
||||||
SAST_GOSEC_LEVEL \
|
|
||||||
SAST_FLAWFINDER_LEVEL \
|
|
||||||
SAST_DOCKER_CLIENT_NEGOTIATION_TIMEOUT \
|
|
||||||
SAST_PULL_ANALYZER_IMAGE_TIMEOUT \
|
|
||||||
SAST_RUN_ANALYZER_TIMEOUT \
|
|
||||||
) \
|
|
||||||
--volume "$PWD:/code" \
|
|
||||||
--volume /var/run/docker.sock:/var/run/docker.sock \
|
|
||||||
"registry.gitlab.com/gitlab-org/security-products/sast:$SP_VERSION" /app/bin/run /code
|
|
||||||
artifacts:
|
|
||||||
reports:
|
|
||||||
sast: gl-sast-report.json
|
|
||||||
|
|
||||||
dependency_scanning:
|
dependency_scanning:
|
||||||
extends: .dedicated-no-docs-no-db-pull-cache-job
|
|
||||||
image: docker:stable
|
|
||||||
variables:
|
|
||||||
DOCKER_DRIVER: overlay2
|
|
||||||
allow_failure: true
|
|
||||||
tags: []
|
|
||||||
before_script: []
|
before_script: []
|
||||||
cache: {}
|
tags: []
|
||||||
dependencies: []
|
extends: .dedicated-no-docs
|
||||||
services:
|
|
||||||
- docker:stable-dind
|
|
||||||
script:
|
|
||||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
|
||||||
- | # this is required to avoid undesirable reset of Docker image ENV variables being set on build stage
|
|
||||||
function propagate_env_vars() {
|
|
||||||
CURRENT_ENV=$(printenv)
|
|
||||||
|
|
||||||
for VAR_NAME; do
|
|
||||||
echo $CURRENT_ENV | grep "${VAR_NAME}=" > /dev/null && echo "--env $VAR_NAME "
|
|
||||||
done
|
|
||||||
}
|
|
||||||
- |
|
|
||||||
docker run \
|
|
||||||
$(propagate_env_vars \
|
|
||||||
DS_ANALYZER_IMAGES \
|
|
||||||
DS_ANALYZER_IMAGE_PREFIX \
|
|
||||||
DS_ANALYZER_IMAGE_TAG \
|
|
||||||
DS_DEFAULT_ANALYZERS \
|
|
||||||
DEP_SCAN_DISABLE_REMOTE_CHECKS \
|
|
||||||
DS_DOCKER_CLIENT_NEGOTIATION_TIMEOUT \
|
|
||||||
DS_PULL_ANALYZER_IMAGE_TIMEOUT \
|
|
||||||
DS_RUN_ANALYZER_TIMEOUT \
|
|
||||||
) \
|
|
||||||
--volume "$PWD:/code" \
|
|
||||||
--volume /var/run/docker.sock:/var/run/docker.sock \
|
|
||||||
"registry.gitlab.com/gitlab-org/security-products/dependency-scanning:$SP_VERSION" /code
|
|
||||||
artifacts:
|
|
||||||
reports:
|
|
||||||
dependency_scanning: gl-dependency-scanning-report.json
|
|
||||||
|
|
5
changelogs/unreleased/60879-fix-reports-timing-out.yml
Normal file
5
changelogs/unreleased/60879-fix-reports-timing-out.yml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Fix reports jobs timing out because of cache
|
||||||
|
merge_request: 29780
|
||||||
|
author:
|
||||||
|
type: fixed
|
Loading…
Reference in a new issue