Commit 39457e88 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Make code around final build state update more readable

parent d9ad1e4d
...@@ -28,7 +28,7 @@ module Ci ...@@ -28,7 +28,7 @@ module Ci
private private
def accept_build_state! def accept_build_state!
if ACCEPT_TIMEOUT.ago > ensure_pending_state.created_at if Time.current - ensure_pending_state.created_at > ACCEPT_TIMEOUT
metrics.increment_trace_operation(operation: :discarded) metrics.increment_trace_operation(operation: :discarded)
return update_build_state! return update_build_state!
...@@ -116,7 +116,7 @@ module Ci ...@@ -116,7 +116,7 @@ module Ci
failure_reason: params.dig(:failure_reason) failure_reason: params.dig(:failure_reason)
) )
rescue ActiveRecord::RecordNotFound rescue ActiveRecord::RecordNotFound
metrics.increment_trace_operation(operation: :flaky) metrics.increment_trace_operation(operation: :conflict)
build.pending_state build.pending_state
end end
......
...@@ -202,12 +202,12 @@ RSpec.describe Ci::UpdateBuildStateService do ...@@ -202,12 +202,12 @@ RSpec.describe Ci::UpdateBuildStateService do
expect(result.status).to eq 200 expect(result.status).to eq 200
end end
it 'increments flaky trace metric' do it 'increments conflict trace metric' do
subject.execute subject.execute
expect(metrics) expect(metrics)
.to have_received(:increment_trace_operation) .to have_received(:increment_trace_operation)
.with(operation: :flaky) .with(operation: :conflict)
end end
end 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