Gitlab maintenance

Cleanup

Orphaned artifacts

sudo gitlab-rake gitlab:cleanup:orphan_job_artifact_files
 
I, [2020-07-09T06:53:53.293070 #17939]  INFO -- : [DRY RUN] Looking for orphan job artifacts to clean up
I, [2020-07-09T06:53:53.293493 #17939]  INFO -- : [DRY RUN] find command: '/usr/bin/ionice -c best-effort find -L /var/opt/gitlab/gitlab-rails/shared/artifacts -mindepth 6 -maxdepth 6 -type d'
I, [2020-07-09T06:53:56.433277 #17939]  INFO -- : [DRY RUN] Processed 134037 job artifact(s) to find and cleaned 55761 orphan(s).
I, [2020-07-09T06:53:56.433444 #17939]  INFO -- : To clean up these files run this command with DRY_RUN=false
 
sudo gitlab-rake gitlab:cleanup:orphan_job_artifact_files DRY_RUN=false
I, [2020-07-09T06:54:44.061772 #18110]  INFO -- :  Looking for orphan job artifacts to clean up
I, [2020-07-09T06:54:44.061940 #18110]  INFO -- :  find command: '/usr/bin/ionice -c best-effort find -L /var/opt/gitlab/gitlab-rails/shared/artifacts -mindepth 6 -maxdepth 6 -type d'
I, [2020-07-09T06:54:51.099409 #18110]  INFO -- :  Processed 134037 job artifact(s) to find and cleaned 55761 orphan(s).

Not expired artifacts

On Gitlab server:

sudo apt-get remove python-pip
sudo apt-get install python3-pip
pip3 install --upgrade pip
 
sudo apt-get install postgresql postgresql-server-dev-all
sudo systemctl disable --now postgresql.service
 
sudo pip install \
      'grpcio>=1.15.0' \
      'protobuf>=3.6.1' \
      'psycopg2>=2.6' \
      'pyyaml>=3.11'
 
sudo pip install glartifacts

Usage:

glartifacts list
 
glartifacts remove --strategy LASTGOOD_PIPELINE --dry-run group/subgroup/project
 
glartifacts remove --strategy LASTGOOD_PIPELINE --all
 
# by default Sidekiq task 'cronjob:expire_build_artifacts' is running every 50 minutes, force it now
# Go to https://gitlab.example.com/admin/background_jobs --> "Cron" tab and "enqueue Now"
# and check results:
glartifacts list

Job logs

Hundreds of jobs with build log size of 16MB can occupy gigabytes on disk. Job artifacts using too much disk space