diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-20 17:22:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-20 17:22:11 +0300 |
commit | 0c872e02b2c822e3397515ec324051ff540f0cd5 (patch) | |
tree | ce2fb6ce7030e4dad0f4118d21ab6453e5938cdd /app/services/ci/create_downstream_pipeline_service.rb | |
parent | f7e05a6853b12f02911494c4b3fe53d9540d74fc (diff) |
Add latest changes from gitlab-org/gitlab@15-7-stable-eev15.7.0-rc42
Diffstat (limited to 'app/services/ci/create_downstream_pipeline_service.rb')
-rw-r--r-- | app/services/ci/create_downstream_pipeline_service.rb | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/app/services/ci/create_downstream_pipeline_service.rb b/app/services/ci/create_downstream_pipeline_service.rb index 25cc9045052..3d0a7fb99ea 100644 --- a/app/services/ci/create_downstream_pipeline_service.rb +++ b/app/services/ci/create_downstream_pipeline_service.rb @@ -11,24 +11,25 @@ module Ci DuplicateDownstreamPipelineError = Class.new(StandardError) MAX_NESTED_CHILDREN = 2 - MAX_HIERARCHY_SIZE = 1000 def execute(bridge) @bridge = bridge - if bridge.has_downstream_pipeline? + if @bridge.has_downstream_pipeline? Gitlab::ErrorTracking.track_exception( DuplicateDownstreamPipelineError.new, bridge_id: @bridge.id, project_id: @bridge.project_id ) - return error('Already has a downstream pipeline') + return ServiceResponse.error(message: 'Already has a downstream pipeline') end pipeline_params = @bridge.downstream_pipeline_params target_ref = pipeline_params.dig(:target_revision, :ref) - return error('Pre-conditions not met') unless ensure_preconditions!(target_ref) + return ServiceResponse.error(message: 'Pre-conditions not met') unless ensure_preconditions!(target_ref) + + return ServiceResponse.error(message: 'Can not run the bridge') unless @bridge.run service = ::Ci::CreatePipelineService.new( pipeline_params.fetch(:project), @@ -40,10 +41,7 @@ module Ci .payload log_downstream_pipeline_creation(downstream_pipeline) - - downstream_pipeline.tap do |pipeline| - update_bridge_status!(@bridge, pipeline) - end + update_bridge_status!(@bridge, downstream_pipeline) end private @@ -54,9 +52,12 @@ module Ci # If bridge uses `strategy:depend` we leave it running # and update the status when the downstream pipeline completes. subject.success! unless subject.dependent? + ServiceResponse.success(payload: pipeline) else - subject.options[:downstream_errors] = pipeline.errors.full_messages + message = pipeline.errors.full_messages + subject.options[:downstream_errors] = message subject.drop!(:downstream_pipeline_creation_failed) + ServiceResponse.error(payload: pipeline, message: message) end end rescue StateMachines::InvalidTransition => e @@ -64,6 +65,7 @@ module Ci Ci::Bridge::InvalidTransitionError.new(e.message), bridge_id: bridge.id, downstream_pipeline_id: pipeline.id) + ServiceResponse.error(payload: pipeline, message: e.message) end def ensure_preconditions!(target_ref) @@ -151,7 +153,13 @@ module Ci return false unless @bridge.triggers_downstream_pipeline? # Applies to the entire pipeline tree across all projects - @bridge.pipeline.complete_hierarchy_count >= MAX_HIERARCHY_SIZE + # A pipeline tree can be shared between multiple namespaces (customers), the limit that is used here + # is the limit of the namespace that has added a downstream pipeline to a pipeline tree. + @bridge.project.actual_limits.exceeded?(:pipeline_hierarchy_size, complete_hierarchy_count) + end + + def complete_hierarchy_count + @bridge.pipeline.complete_hierarchy_count end def config_checksum(pipeline) |