Fix runner eternal loop when update job result

Add spec

Add changelog
This commit is contained in:
Shinya Maeda 2019-01-18 19:15:00 +09:00
parent 35c3cb7c48
commit 91c1dc578e
3 changed files with 31 additions and 1 deletions

View File

@ -224,8 +224,15 @@ module Ci
before_transition any => [:failed] do |build|
next unless build.project
next unless build.deployment
build.deployment&.drop
begin
build.deployment.drop!
rescue => e
Gitlab::Sentry.track_exception(e, extra: { build_id: build.id })
end
true
end
after_transition any => [:failed] do |build|

View File

@ -0,0 +1,5 @@
---
title: Fix runner eternal loop when update job result
merge_request: 24481
author:
type: fixed

View File

@ -3028,6 +3028,24 @@ describe Ci::Build do
subject.drop!
end
end
context 'when associated deployment failed to update its status' do
let(:build) { create(:ci_build, :running, pipeline: pipeline) }
let!(:deployment) { create(:deployment, deployable: build) }
before do
allow_any_instance_of(Deployment)
.to receive(:drop!).and_raise('Unexpected error')
end
it 'can drop the build' do
expect(Gitlab::Sentry).to receive(:track_exception)
expect { build.drop! }.not_to raise_error
expect(build).to be_failed
end
end
end
describe '.matches_tag_ids' do