Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzegorz@gitlab.com>2019-08-14 18:05:51 +0300
committerGrzegorz Bizon <grzegorz@gitlab.com>2019-08-14 18:05:51 +0300
commit8fc2fbb6f2192fb77e2efedf40002ba0a009748e (patch)
tree0d2ac82b147cc0b62374379290028c84c8b39131 /lib
parentecee476abaef56c315b6f4320bece7895ba4d886 (diff)
parentfcc20fde8346a9c2dd9e79ded2557c8058ac1e22 (diff)
Merge branch 'limit-amount-of-needs' into 'master'
Add `ci_dag_limit_needs` See merge request gitlab-org/gitlab-ce!31803
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/ci/pipeline/seed/build.rb20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/gitlab/ci/pipeline/seed/build.rb b/lib/gitlab/ci/pipeline/seed/build.rb
index 32086735556..b0ce7457926 100644
--- a/lib/gitlab/ci/pipeline/seed/build.rb
+++ b/lib/gitlab/ci/pipeline/seed/build.rb
@@ -9,6 +9,10 @@ module Gitlab
delegate :dig, to: :@attributes
+ # When the `ci_dag_limit_needs` is enabled it uses the lower limit
+ LOW_NEEDS_LIMIT = 5
+ HARD_NEEDS_LIMIT = 50
+
def initialize(pipeline, attributes, previous_stages)
@pipeline = pipeline
@attributes = attributes
@@ -77,9 +81,15 @@ module Gitlab
end
def needs_errors
- return unless Feature.enabled?(:ci_dag_support, @pipeline.project)
return if @needs_attributes.nil?
+ if @needs_attributes.size > max_needs_allowed
+ return [
+ "#{name}: one job can only need #{max_needs_allowed} others, but you have listed #{@needs_attributes.size}. " \
+ "See needs keyword documentation for more details"
+ ]
+ end
+
@needs_attributes.flat_map do |need|
result = @previous_stages.any? do |stage|
stage.seeds_names.include?(need[:name])
@@ -88,6 +98,14 @@ module Gitlab
"#{name}: needs '#{need[:name]}'" unless result
end.compact
end
+
+ def max_needs_allowed
+ if Feature.enabled?(:ci_dag_limit_needs, @project, default_enabled: true)
+ LOW_NEEDS_LIMIT
+ else
+ HARD_NEEDS_LIMIT
+ end
+ end
end
end
end