Commit d4d5e685 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'track-transition-errors-in-bridge-status' into 'master'

Track transition error on concurrent bridge update

See merge request gitlab-org/gitlab!26566
parents 279076b3 3566fb4b
...@@ -10,6 +10,7 @@ module Ci ...@@ -10,6 +10,7 @@ module Ci
include HasRef include HasRef
InvalidBridgeTypeError = Class.new(StandardError) InvalidBridgeTypeError = Class.new(StandardError)
InvalidTransitionError = Class.new(StandardError)
belongs_to :project belongs_to :project
belongs_to :trigger_request belongs_to :trigger_request
......
...@@ -52,6 +52,11 @@ module Ci ...@@ -52,6 +52,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(
Ci::Bridge::InvalidTransitionError.new(e.message),
bridge_id: bridge.id,
downstream_pipeline_id: pipeline.id)
end end
def ensure_preconditions!(target_ref) def ensure_preconditions!(target_ref)
......
...@@ -5,7 +5,14 @@ module Ci ...@@ -5,7 +5,14 @@ module Ci
def execute(pipeline) def execute(pipeline)
return unless pipeline.bridge_triggered? return unless pipeline.bridge_triggered?
pipeline.source_bridge.inherit_status_from_downstream!(pipeline) begin
pipeline.source_bridge.inherit_status_from_downstream!(pipeline)
rescue StateMachines::InvalidTransition => e
Gitlab::ErrorTracking.track_exception(
Ci::Bridge::InvalidTransitionError.new(e.message),
bridge_id: pipeline.source_bridge.id,
downstream_pipeline_id: pipeline.id)
end
end end
end end
end end
......
...@@ -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::Bridge::InvalidTransitionError),
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 }]
......
...@@ -22,6 +22,24 @@ describe Ci::PipelineBridgeStatusService do ...@@ -22,6 +22,24 @@ describe Ci::PipelineBridgeStatusService do
subject subject
end end
context 'when bridge job status raises state machine errors' do
before do
pipeline.drop!
bridge.drop!
end
it 'tracks the exception' do
expect(Gitlab::ErrorTracking)
.to receive(:track_exception)
.with(
instance_of(Ci::Bridge::InvalidTransitionError),
bridge_id: bridge.id,
downstream_pipeline_id: pipeline.id)
subject
end
end
end end
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