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