2018-06-27 07:23:28 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-06-10 15:27:49 +00:00
|
|
|
class ExpireBuildArtifactsWorker
|
2017-11-28 16:08:30 +00:00
|
|
|
include ApplicationWorker
|
2016-10-21 16:13:41 +00:00
|
|
|
include CronjobQueue
|
2016-05-18 20:21:51 +00:00
|
|
|
|
|
|
|
def perform
|
2019-01-17 06:06:37 +00:00
|
|
|
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
|
2016-10-07 09:11:02 +00:00
|
|
|
Rails.logger.info 'Scheduling removal of build artifacts'
|
2016-05-18 20:21:51 +00:00
|
|
|
|
2016-10-07 09:11:02 +00:00
|
|
|
build_ids = Ci::Build.with_expired_artifacts.pluck(:id)
|
|
|
|
build_ids = build_ids.map { |build_id| [build_id] }
|
|
|
|
|
2017-11-29 15:30:17 +00:00
|
|
|
ExpireBuildInstanceArtifactsWorker.bulk_perform_async(build_ids)
|
2016-05-18 20:21:51 +00:00
|
|
|
end
|
2018-08-27 15:31:01 +00:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2016-05-18 20:21:51 +00:00
|
|
|
end
|