summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2019-01-18 11:30:43 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2019-01-18 11:30:43 +0000
commit20de391b7b2b1322297b5e09c5dbcca062b113a3 (patch)
tree1fb7e69f0fb5d759791b9314a086d66c4e6eda39
parent75ead9a4f34f392b3595afb7a15de173c1f980b8 (diff)
parent91c1dc578eba70417b05ef0edd961f0717e10c43 (diff)
downloadgitlab-ce-20de391b7b2b1322297b5e09c5dbcca062b113a3.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
-rw-r--r--app/models/ci/build.rb9
-rw-r--r--changelogs/unreleased/fix-runner-eternal-loop-when-update-job-result.yml5
-rw-r--r--spec/models/ci/build_spec.rb18
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