Skip to content

Cleanup build directory with feature flag

John Cai requested to merge jc-cleanup-build-dirs into main

What does this MR do?

If feature flag FF_ENABLE_CLEANUP is set to true, run a step at the end of the build to clean up the build directory.

Why was this MR needed?

Currently builds can leave artifacts around in the build directory taking up more and more space on the disk over time.

What's the best way to test this MR?

To evaluate the implementation, consider the following scenario of a shell executor running inside an alpine:latest Docker container:

.gitlab-ci.yml
job:
  script:
    - truncate -s 2G artifact.bin
    - df -k -h ${CI_BUILDS_DIR}
  artifacts:
    paths:
      - artifact.bin
config.toml
concurrent = 1
check_interval = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "shell runner"
  url = "https://gitlab.com/"
  executor = "shell"
  executor = "bash"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]

Running this job multiple times should not result in increasing values reported in the Used column of the df tool output. The same should be true with concurrent > 1 once we've saturated the number of allowed concurrent builds (meaning that a directory has been created for each of the possible concurrent jobs under $CI_BUILDS_DIR/$CI_RUNNER_SHORT_TOKEN).

What are the relevant issue numbers?

Closes #3856 (closed)

Edited by Georgi N. Georgiev

Merge request reports