Skip to content

Impossible to remove orphan artifact files

Summary

On gitlab 12.8.5, Impossible to remove orphan artifact files.

Steps to reproduce

gitlab-rake gitlab:cleanup:orphan_job_artifact_files DEBUG=1
I, [2020-03-20T15:03:52.200239 #40154]  INFO -- : [DRY RUN] Looking for orphan job artifacts to clean up
I, [2020-03-20T15:03:52.200624 #40154]  INFO -- : [DRY RUN] find command: '/usr/bin/ionice --class best-effort find -L /var/opt/gitlab/gitlab-rails/shared/artifacts -mindepth 6 -maxdepth 6 -type d'
E, [2020-03-20T15:03:52.204031 #40154] ERROR -- : /usr/bin/ionice : option invalide -- '-'

D, [2020-03-20T15:03:52.237378 #40154] DEBUG -- : Found orphan job artifact file @
D, [2020-03-20T15:03:52.237449 #40154] DEBUG -- : Found orphan job artifact file @ ionice - sets or gets process io scheduling class and priority.
D, [2020-03-20T15:03:52.237482 #40154] DEBUG -- : Found orphan job artifact file @
D, [2020-03-20T15:03:52.237510 #40154] DEBUG -- : Found orphan job artifact file @ Usage:
D, [2020-03-20T15:03:52.237536 #40154] DEBUG -- : Found orphan job artifact file @   ionice [ options ] -p <pid> [<pid> ...]
D, [2020-03-20T15:03:52.237565 #40154] DEBUG -- : Found orphan job artifact file @   ionice [ options ] <command> [<arg> ...]
D, [2020-03-20T15:03:52.237592 #40154] DEBUG -- : Found orphan job artifact file @
D, [2020-03-20T15:03:52.237617 #40154] DEBUG -- : Found orphan job artifact file @ Options:
D, [2020-03-20T15:03:52.237644 #40154] DEBUG -- : Found orphan job artifact file @   -n <classdata>      class data (0-7, lower being higher prio)
D, [2020-03-20T15:03:52.237670 #40154] DEBUG -- : Found orphan job artifact file @   -c <class>          scheduling class
D, [2020-03-20T15:03:52.237697 #40154] DEBUG -- : Found orphan job artifact file @                       0: none, 1: realtime, 2: best-effort, 3: idle
D, [2020-03-20T15:03:52.237742 #40154] DEBUG -- : Found orphan job artifact file @   -t                  ignore failures
D, [2020-03-20T15:03:52.237771 #40154] DEBUG -- : Found orphan job artifact file @   -h                  this help
D, [2020-03-20T15:03:52.237798 #40154] DEBUG -- : Found orphan job artifact file @
I, [2020-03-20T15:03:52.237865 #40154]  INFO -- : [DRY RUN] Processed 14 job artifact(s) to find and cleaned 14 orphan(s).
I, [2020-03-20T15:03:52.237953 #40154]  INFO -- : To clean up these files run this command with DRY_RUN=false

Possible fixes

Change lib/gitlab/cleanup/orphan_job_artifact_files.rb

Replace line 105

cmd.unshift(*%W[#{ionice} --class #{niceness}])

By

cmd.unshift(*%W[#{ionice} -c #{niceness}])