Commit 99a695e1 authored by Fabio Pitino's avatar Fabio Pitino

Run sync BuildFinishedWorker operations always before

- Ensure that async operations in EE always run
  after the sync code.

Changelog: fixed
EE: true
parent 106f6bec
......@@ -4,6 +4,11 @@ module EE
module Ci
module BuildFinishedWorker
def process_build(build)
# Always run `super` first since it contains sync operations.
# Failing to run sync operations would cause the worker to retry
# and enqueueing duplicate jobs.
super
unless ::Feature.enabled?(:cancel_pipelines_prior_to_destroy, build.project, default_enabled: :yaml)
::Ci::Minutes::UpdateBuildMinutesService.new(build.project, nil).execute(build)
end
......@@ -15,8 +20,6 @@ module EE
if ::Gitlab.com? && build.has_security_reports?
::Security::TrackSecureScansWorker.perform_async(build.id)
end
super
end
end
end
......
......@@ -56,6 +56,20 @@ RSpec.describe Ci::BuildFinishedWorker do
subject
end
context 'when exception is raised in `super`' do
before do
allow(::BuildHooksWorker)
.to receive(:perform_async)
.and_raise(ArgumentError)
end
it 'does not enqueue the worker in EE' do
expect { subject }.to raise_error(ArgumentError)
expect(::Security::TrackSecureScansWorker).not_to receive(:perform_async)
end
end
context 'when build does not have a security report' do
let(:build) { create(:ee_ci_build, :success, runner: ci_runner) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment