2021-09-30 23:02:18 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Ci
|
|
|
|
class BuildFinishedWorker # rubocop:disable Scalability/IdempotentWorker
|
|
|
|
include ApplicationWorker
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
data_consistency :always
|
|
|
|
|
2021-09-30 23:02:18 +05:30
|
|
|
sidekiq_options retry: 3
|
|
|
|
include PipelineQueue
|
|
|
|
|
|
|
|
queue_namespace :pipeline_processing
|
|
|
|
urgency :high
|
|
|
|
worker_resource_boundary :cpu
|
|
|
|
|
|
|
|
ARCHIVE_TRACES_IN = 2.minutes.freeze
|
|
|
|
|
|
|
|
def perform(build_id)
|
2021-12-11 22:18:48 +05:30
|
|
|
return unless build = Ci::Build.find_by_id(build_id)
|
2021-11-18 22:05:49 +05:30
|
|
|
return unless build.project
|
|
|
|
return if build.project.pending_delete?
|
|
|
|
|
|
|
|
process_build(build)
|
2021-09-30 23:02:18 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
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.
|
|
|
|
build.update_coverage
|
|
|
|
Ci::BuildReportResultService.new.execute(build)
|
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
build.feature_flagged_execute_hooks
|
2021-09-30 23:02:18 +05:30
|
|
|
ChatNotificationWorker.perform_async(build.id) if build.pipeline.chat?
|
2022-05-07 20:08:51 +05:30
|
|
|
build.track_deployment_usage
|
2022-08-13 15:12:31 +05:30
|
|
|
build.track_verify_usage
|
2021-09-30 23:02:18 +05:30
|
|
|
|
2022-03-02 08:16:31 +05:30
|
|
|
if build.failed? && !build.auto_retry_expected?
|
2021-09-30 23:02:18 +05:30
|
|
|
::Ci::MergeRequests::AddTodoWhenBuildFailsWorker.perform_async(build.id)
|
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# 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.
|
|
|
|
#
|
2022-08-13 15:12:31 +05:30
|
|
|
Ci::ArchiveTraceWorker.perform_in(ARCHIVE_TRACES_IN, build.id)
|
2021-09-30 23:02:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Ci::BuildFinishedWorker.prepend_mod_with('Ci::BuildFinishedWorker')
|