Commit 1d88c7bc authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'sh-handle-unknown-failure-reasons' into 'master'

Gracefully handle unknown failure reason in runner CI job

See merge request gitlab-org/gitlab!63828
parents 39e1dce2 4e521476
......@@ -169,7 +169,7 @@ module Ci
state: params.fetch(:state),
trace_checksum: trace_checksum,
trace_bytesize: trace_bytesize,
failure_reason: params.dig(:failure_reason)
failure_reason: failure_reason
)
unless build_state.present?
......@@ -179,6 +179,14 @@ module Ci
build_state || build.pending_state
end
def failure_reason
reason = params.dig(:failure_reason)
return unless reason
Ci::BuildPendingState.failure_reasons.fetch(reason.to_s, 'unknown_failure')
end
##
# This method is releasing an exclusive lock on a build trace the moment we
# conclude that build status has been written and the build state update
......
......@@ -15,6 +15,24 @@ RSpec.describe Ci::UpdateBuildStateService do
stub_feature_flags(ci_enable_live_trace: true)
end
context 'when build has unknown failure reason' do
let(:params) do
{
output: { checksum: 'crc32:12345678', bytesize: 123 },
state: 'failed',
failure_reason: 'no idea here',
exit_code: 42
}
end
it 'updates a build status' do
result = subject.execute
expect(build).to be_failed
expect(result.status).to eq 200
end
end
context 'when build does not have checksum' do
context 'when state has changed' do
let(:params) { { state: 'success' } }
......
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