Commit aa6d09db authored by Grzegorz Bizon's avatar Grzegorz Bizon

Improve code around logging finalized build traces

parent c61415d6
......@@ -20,6 +20,7 @@ module Ci
if accept_request?
accept_build_state!
else
check_migration_state
update_build_state!
end
end
......@@ -48,12 +49,15 @@ module Ci
build.trace.set(params[:trace]) if Gitlab::Ci::Features.trace_overwrite?
end
def update_build_state!
# TODO, simplify this, doesn't work in case of timeout too
if accept_available? && has_chunks?
def check_migration_state
return unless accept_available?
if has_chunks? && !live_chunks_pending?
metrics.increment_trace_operation(operation: :finalized)
end
end
def update_build_state!
case build_state
when 'running'
build.touch if build.needs_touch?
......
......@@ -178,6 +178,14 @@ RSpec.describe Ci::UpdateBuildStateService do
.to have_received(:increment_trace_operation)
.with(operation: :discarded)
end
it 'does not increment finalized trace metric' do
subject.execute
expect(metrics)
.not_to have_received(:increment_trace_operation)
.with(operation: :finalized)
end
end
context 'when build pending state has changes' do
......
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