diff options
author | Kamil TrzciĆski <ayufan@ayufan.eu> | 2019-01-18 11:30:43 +0000 |
---|---|---|
committer | GitLab Release Tools Bot <robert+release-tools@gitlab.com> | 2019-01-18 14:38:33 +0000 |
commit | 6d2c02a0d79a089508922425c6aab66ef8d2d131 (patch) | |
tree | 87171aacd5cdfe46e87b9547b0418d851270e416 | |
parent | a2d63468f7446ae92547d8ef9d27de7bfe784f02 (diff) | |
download | gitlab-ce-6d2c02a0d79a089508922425c6aab66ef8d2d131.tar.gz |
Merge branch 'fix-runner-eternal-loop-when-update-job-result' into 'master'
Fix runner eternal loop when update job result
Closes #56518
See merge request gitlab-org/gitlab-ce!24481
(cherry picked from commit 20de391b7b2b1322297b5e09c5dbcca062b113a3)
91c1dc57 Fix runner eternal loop when update job result
-rw-r--r-- | app/models/ci/build.rb | 9 | ||||
-rw-r--r-- | changelogs/unreleased/fix-runner-eternal-loop-when-update-job-result.yml | 5 | ||||
-rw-r--r-- | spec/models/ci/build_spec.rb | 18 |
3 files changed, 31 insertions, 1 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index dc6f8ae1a7f..cfdb3c0d719 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -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| diff --git a/changelogs/unreleased/fix-runner-eternal-loop-when-update-job-result.yml b/changelogs/unreleased/fix-runner-eternal-loop-when-update-job-result.yml new file mode 100644 index 00000000000..5a6c36e6f5f --- /dev/null +++ b/changelogs/unreleased/fix-runner-eternal-loop-when-update-job-result.yml @@ -0,0 +1,5 @@ +--- +title: Fix runner eternal loop when update job result +merge_request: 24481 +author: +type: fixed diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 1afc2436bb5..60d89313f07 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -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 |