gitlab-org--gitlab-foss/app/workers/expire_build_artifacts_worker.rb

30 lines
808 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2016-06-10 11:27:49 -04:00
class ExpireBuildArtifactsWorker
include ApplicationWorker
include CronjobQueue
2016-05-18 16:21:51 -04:00
def perform
if Feature.enabled?(:ci_new_expire_job_artifacts_service, default_enabled: true)
perform_efficient_artifacts_removal
else
perform_legacy_artifacts_removal
end
end
def perform_efficient_artifacts_removal
Ci::DestroyExpiredJobArtifactsService.new.execute
end
# rubocop: disable CodeReuse/ActiveRecord
def perform_legacy_artifacts_removal
Rails.logger.info 'Scheduling removal of build artifacts'
2016-05-18 16:21:51 -04:00
build_ids = Ci::Build.with_expired_artifacts.pluck(:id)
build_ids = build_ids.map { |build_id| [build_id] }
2017-11-29 10:30:17 -05:00
ExpireBuildInstanceArtifactsWorker.bulk_perform_async(build_ids)
2016-05-18 16:21:51 -04:00
end
# rubocop: enable CodeReuse/ActiveRecord
2016-05-18 16:21:51 -04:00
end