Commit 5bf9da3d authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'capture-ci-minutes-reset-errors' into 'master'

Capture errors raised for a batch when resetting CI minutes

See merge request gitlab-org/gitlab!41888
parents 008dbea2 1ef5bc11
......@@ -35,8 +35,8 @@ module Ci
reset_shared_runners_seconds!(namespaces)
reset_ci_minutes_notifications!(namespaces)
end
rescue ActiveRecord::ActiveRecordError
@errors << { count: namespaces.size, first_id: namespaces.first.id, last_id: namespaces.last.id }
rescue ActiveRecord::ActiveRecordError => e
@errors << { count: namespaces.size, first_id: namespaces.first.id, last_id: namespaces.last.id, error: e.message }
end
# This service is responsible for the logic that recalculates the extra shared runners
......
......@@ -4,6 +4,7 @@ module Ci
class BatchResetMinutesWorker
include ApplicationWorker
sidekiq_options retry: 10
feature_category :continuous_integration
idempotent!
......
......@@ -138,7 +138,7 @@ RSpec.describe Ci::Minutes::BatchResetService do
let(:ids_range) { nil }
before do
expect(Namespace).to receive(:transaction).once.ordered.and_raise(ActiveRecord::ActiveRecordError)
expect(Namespace).to receive(:transaction).once.ordered.and_raise(ActiveRecord::ActiveRecordError, 'something went wrong')
expect(Namespace).to receive(:transaction).once.ordered.and_call_original
end
......@@ -157,7 +157,7 @@ RSpec.describe Ci::Minutes::BatchResetService do
Ci::Minutes::BatchResetService::BatchNotResetError.new(
'Some namespace shared runner minutes were not reset.'
),
{ namespace_ranges: [{ count: 3, first_id: 1, last_id: 3 }] }
{ namespace_ranges: [{ count: 3, first_id: 1, last_id: 3, error: 'something went wrong' }] }
).once.and_call_original
expect { subject }.to raise_error(Ci::Minutes::BatchResetService::BatchNotResetError)
......
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