Commit 781cd4a2 authored by Tiger's avatar Tiger

Rescue and log errors raised when preparing builds

https://gitlab.com/gitlab-org/gitlab-ce/issues/60480
parent 0a99e022
......@@ -11,9 +11,11 @@ module Ci
def execute
prerequisites.each(&:complete!)
unless build.enqueue
build.drop!(:unmet_prerequisites)
end
build.enqueue!
rescue => e
Gitlab::Sentry.track_acceptable_exception(e, extra: { build_id: build.id })
build.drop(:unmet_prerequisites)
end
private
......
......@@ -38,7 +38,21 @@ describe Ci::PrepareBuildService do
end
it 'drops the build' do
expect(build).to receive(:drop!).with(:unmet_prerequisites).once
expect(build).to receive(:drop).with(:unmet_prerequisites).once
subject
end
end
context 'prerequisites raise an error' do
before do
allow(prerequisite).to receive(:complete!).and_raise Kubeclient::HttpError.new(401, 'unauthorized', nil)
end
it 'drops the build and notifies Sentry' do
expect(build).to receive(:drop).with(:unmet_prerequisites).once
expect(Gitlab::Sentry).to receive(:track_acceptable_exception)
.with(instance_of(Kubeclient::HttpError), hash_including(extra: { build_id: build.id }))
subject
end
......
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