Commit 67ada8d4 authored by Fabio Pitino's avatar Fabio Pitino

Track transition error on concurrent bridge update

parent 0a136b97
...@@ -6,6 +6,7 @@ module Ci ...@@ -6,6 +6,7 @@ module Ci
include Gitlab::Utils::StrongMemoize include Gitlab::Utils::StrongMemoize
DuplicateDownstreamPipelineError = Class.new(StandardError) DuplicateDownstreamPipelineError = Class.new(StandardError)
InvalidBridgeTransition = Class.new(StandardError)
def execute(bridge) def execute(bridge)
@bridge = bridge @bridge = bridge
...@@ -52,6 +53,11 @@ module Ci ...@@ -52,6 +53,11 @@ module Ci
subject.drop!(:downstream_pipeline_creation_failed) subject.drop!(:downstream_pipeline_creation_failed)
end end
end end
rescue StateMachines::InvalidTransition => e
Gitlab::ErrorTracking.track_exception(
InvalidBridgeTransition.new(e.message),
bridge_id: bridge.id,
downstream_pipeline_id: pipeline.id)
end end
def ensure_preconditions!(target_ref) def ensure_preconditions!(target_ref)
......
...@@ -362,6 +362,26 @@ describe Ci::CreateCrossProjectPipelineService, '#execute' do ...@@ -362,6 +362,26 @@ describe Ci::CreateCrossProjectPipelineService, '#execute' do
end end
end end
context 'when bridge job status update raises state machine errors' do
let(:stub_config) { false }
before do
stub_ci_pipeline_yaml_file(YAML.dump(invalid: { yaml: 'error' }))
bridge.drop!
end
it 'tracks the exception' do
expect(Gitlab::ErrorTracking)
.to receive(:track_exception)
.with(
instance_of(Ci::CreateCrossProjectPipelineService::InvalidBridgeTransition),
bridge_id: bridge.id,
downstream_pipeline_id: kind_of(Numeric))
service.execute(bridge)
end
end
context 'when bridge job has YAML variables defined' do context 'when bridge job has YAML variables defined' do
before do before do
bridge.yaml_variables = [{ key: 'BRIDGE', value: 'var', public: true }] bridge.yaml_variables = [{ key: 'BRIDGE', value: 'var', public: true }]
......
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