Commit fd1dccce authored by Alishan Ladhani's avatar Alishan Ladhani

Raise an error so that timeouts can be tracked via Sentry

parent cd9a92a9
......@@ -3,6 +3,9 @@
class ChatNotificationWorker
include ApplicationWorker
TimeoutExceeded = Class.new(StandardError)
sidekiq_options retry: false
feature_category :chatops
latency_sensitive_worker!
# TODO: break this into multiple jobs
......@@ -19,7 +22,7 @@ class ChatNotificationWorker
send_response(build)
end
rescue Gitlab::Chat::Output::MissingBuildSectionError
return if timeout_exceeded?(reschedule_count)
raise TimeoutExceeded if timeout_exceeded?(reschedule_count)
# The creation of traces and sections appears to be eventually consistent.
# As a result it's possible for us to run the above code before the trace
......
......@@ -8,6 +8,10 @@ describe ChatNotificationWorker do
create(:ci_build, pipeline: create(:ci_pipeline, source: :chat))
end
it 'instructs sidekiq not to retry on failure' do
expect(described_class.get_sidekiq_options['retry']).to eq(false)
end
describe '#perform' do
it 'does nothing when the build no longer exists' do
expect(worker).not_to receive(:send_response)
......@@ -36,13 +40,13 @@ describe ChatNotificationWorker do
worker.perform(chat_build.id)
end
it "stops rescheduling the job after #{described_class::RESCHEDULE_TIMEOUT} seconds" do
it "raises an error after #{described_class::RESCHEDULE_TIMEOUT} seconds of retrying" do
allow(described_class).to receive(:new).and_return(worker)
allow(worker).to receive(:send_response).and_raise(Gitlab::Chat::Output::MissingBuildSectionError)
worker.perform(chat_build.id)
described_class.drain
expect { described_class.drain }.to raise_error(described_class::TimeoutExceeded)
max_reschedules = described_class::RESCHEDULE_TIMEOUT / described_class::RESCHEDULE_INTERVAL
......
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