summaryrefslogtreecommitdiff
path: root/lib/tasks
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2019-07-01 08:04:57 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2019-07-01 08:04:57 +0000
commitf63dc06cb4572db92bb91c936e9862c55f1f365e (patch)
tree6efbba0d2d30173605f5551eb277822df24a64d7 /lib/tasks
parentbc3ffe835436a32ed46c39e385856cc6fc15db25 (diff)
parentdabd91b2c8a42ac0d0c357190002a5a4b96a57a6 (diff)
downloadgitlab-ce-f63dc06cb4572db92bb91c936e9862c55f1f365e.tar.gz
Merge branch 'tc-rake-orphan-artifacts' into 'master'
Add rake task to clean orphan artifact files See merge request gitlab-org/gitlab-ce!29681
Diffstat (limited to 'lib/tasks')
-rw-r--r--lib/tasks/gitlab/cleanup.rake25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/tasks/gitlab/cleanup.rake b/lib/tasks/gitlab/cleanup.rake
index 760331620ef..105ef417df3 100644
--- a/lib/tasks/gitlab/cleanup.rake
+++ b/lib/tasks/gitlab/cleanup.rake
@@ -115,6 +115,18 @@ namespace :gitlab do
end
end
+ desc 'GitLab | Cleanup | Clean orphan job artifact files'
+ task orphan_job_artifact_files: :gitlab_environment do
+ warn_user_is_not_gitlab
+
+ cleaner = Gitlab::Cleanup::OrphanJobArtifactFiles.new(limit: limit, dry_run: dry_run?, niceness: niceness, logger: logger)
+ cleaner.run!
+
+ if dry_run?
+ logger.info "To clean up these files run this command with DRY_RUN=false".color(:yellow)
+ end
+ end
+
def remove?
ENV['REMOVE'] == 'true'
end
@@ -123,12 +135,25 @@ namespace :gitlab do
ENV['DRY_RUN'] != 'false'
end
+ def debug?
+ ENV['DEBUG'].present?
+ end
+
+ def limit
+ ENV['LIMIT']&.to_i
+ end
+
+ def niceness
+ ENV['NICENESS'].presence
+ end
+
def logger
return @logger if defined?(@logger)
@logger = if Rails.env.development? || Rails.env.production?
Logger.new(STDOUT).tap do |stdout_logger|
stdout_logger.extend(ActiveSupport::Logger.broadcast(Rails.logger))
+ stdout_logger.level = debug? ? Logger::DEBUG : Logger::INFO
end
else
Rails.logger