summaryrefslogtreecommitdiff
path: root/app/services
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-09-15 21:12:27 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-09-15 21:12:27 +0000
commitd657831613232fb95226c076343cd320c6573886 (patch)
tree0c33f1bd5a4f11bb8a33d2a8dc4fe6c3d6c303a9 /app/services
parent99aa31992d4398d35c9df4854f5fb494984a9e0b (diff)
downloadgitlab-ce-d657831613232fb95226c076343cd320c6573886.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services')
-rw-r--r--app/services/ci/create_downstream_pipeline_service.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/app/services/ci/create_downstream_pipeline_service.rb b/app/services/ci/create_downstream_pipeline_service.rb
index c68d990ae2e..25cc9045052 100644
--- a/app/services/ci/create_downstream_pipeline_service.rb
+++ b/app/services/ci/create_downstream_pipeline_service.rb
@@ -11,6 +11,7 @@ module Ci
DuplicateDownstreamPipelineError = Class.new(StandardError)
MAX_NESTED_CHILDREN = 2
+ MAX_HIERARCHY_SIZE = 1000
def execute(bridge)
@bridge = bridge
@@ -86,6 +87,11 @@ module Ci
return false
end
+ if Feature.enabled?(:ci_limit_complete_hierarchy_size) && pipeline_tree_too_large?
+ @bridge.drop!(:reached_max_pipeline_hierarchy_size)
+ return false
+ end
+
unless can_create_downstream_pipeline?(target_ref)
@bridge.drop!(:insufficient_bridge_permissions)
return false
@@ -141,6 +147,13 @@ module Ci
ancestors_of_new_child.count > MAX_NESTED_CHILDREN
end
+ def pipeline_tree_too_large?
+ return false unless @bridge.triggers_downstream_pipeline?
+
+ # Applies to the entire pipeline tree across all projects
+ @bridge.pipeline.complete_hierarchy_count >= MAX_HIERARCHY_SIZE
+ end
+
def config_checksum(pipeline)
[pipeline.project_id, pipeline.ref, pipeline.source].hash
end