2018-06-27 03:23:28 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-02-19 13:09:10 -05:00
|
|
|
class BuildFinishedWorker # rubocop:disable Scalability/IdempotentWorker
|
2017-11-28 11:08:30 -05:00
|
|
|
include ApplicationWorker
|
2017-08-21 08:16:51 -04:00
|
|
|
include PipelineQueue
|
|
|
|
|
2017-11-28 11:16:50 -05:00
|
|
|
queue_namespace :pipeline_processing
|
2020-03-02 13:07:42 -05:00
|
|
|
urgency :high
|
2019-10-30 11:14:17 -04:00
|
|
|
worker_resource_boundary :cpu
|
2020-06-24 14:09:03 -04:00
|
|
|
tags :requires_disk_io
|
2016-10-14 06:53:51 -04:00
|
|
|
|
2020-10-16 11:08:46 -04:00
|
|
|
ARCHIVE_TRACES_IN = 2.minutes.freeze
|
|
|
|
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2016-10-14 06:53:51 -04:00
|
|
|
def perform(build_id)
|
|
|
|
Ci::Build.find_by(id: build_id).try do |build|
|
2019-01-17 10:08:36 -05:00
|
|
|
process_build(build)
|
2016-10-14 06:53:51 -04:00
|
|
|
end
|
|
|
|
end
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2019-01-17 10:08:36 -05:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
# Processes a single CI build that has finished.
|
|
|
|
#
|
|
|
|
# This logic resides in a separate method so that EE can extend it more
|
|
|
|
# easily.
|
|
|
|
#
|
|
|
|
# @param [Ci::Build] build The build to process.
|
|
|
|
def process_build(build)
|
|
|
|
# We execute these in sync to reduce IO.
|
2021-02-05 10:09:28 -05:00
|
|
|
build.parse_trace_sections!
|
|
|
|
build.update_coverage
|
|
|
|
Ci::BuildReportResultService.new.execute(build)
|
2019-01-17 10:08:36 -05:00
|
|
|
|
|
|
|
# We execute these async as these are independent operations.
|
|
|
|
BuildHooksWorker.perform_async(build.id)
|
2020-02-13 13:09:00 -05:00
|
|
|
ExpirePipelineCacheWorker.perform_async(build.pipeline_id) if build.pipeline.cacheable?
|
2019-02-20 16:29:48 -05:00
|
|
|
ChatNotificationWorker.perform_async(build.id) if build.pipeline.chat?
|
2020-10-16 11:08:46 -04:00
|
|
|
|
|
|
|
##
|
|
|
|
# We want to delay sending a build trace to object storage operation to
|
|
|
|
# validate that this fixes a race condition between this and flushing live
|
|
|
|
# trace chunks and chunks being removed after consolidation and putting
|
|
|
|
# them into object storage archive.
|
|
|
|
#
|
|
|
|
# TODO This is temporary fix we should improve later, after we validate
|
|
|
|
# that this is indeed the culprit.
|
|
|
|
#
|
|
|
|
# See https://gitlab.com/gitlab-org/gitlab/-/issues/267112 for more
|
|
|
|
# details.
|
|
|
|
#
|
|
|
|
ArchiveTraceWorker.perform_in(ARCHIVE_TRACES_IN, build.id)
|
2019-01-17 10:08:36 -05:00
|
|
|
end
|
2016-10-14 06:53:51 -04:00
|
|
|
end
|
2019-09-13 09:26:31 -04:00
|
|
|
|
|
|
|
BuildFinishedWorker.prepend_if_ee('EE::BuildFinishedWorker')
|