summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-03-03 00:10:50 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-03-03 00:10:50 +0000
commit8d9c82762d6c4f10f4d3eba5d484179f98c284b0 (patch)
tree4e89532d0d82bfaa1af660a76091528eb4aebc86 /app/models
parenteb1755b2d90efcc161774f66ccd2317ad4c471de (diff)
downloadgitlab-ce-8d9c82762d6c4f10f4d3eba5d484179f98c284b0.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-rw-r--r--app/models/ci/runner.rb30
1 files changed, 25 insertions, 5 deletions
diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb
index 36e61b0d9ec..f9abe6a0acb 100644
--- a/app/models/ci/runner.rb
+++ b/app/models/ci/runner.rb
@@ -253,9 +253,10 @@ module Ci
end
def can_pick?(build)
- return false if self.ref_protected? && !build.protected?
-
- assignable_for?(build.project_id) && accepting_tags?(build)
+ # Run `matches_build?` checks before, since they are cheaper than
+ # `assignable_for?`.
+ #
+ matches_build?(build) && assignable_for?(build.project_id)
end
def only_for?(project)
@@ -266,6 +267,16 @@ module Ci
token[0...8] if token
end
+ def tag_list
+ return super unless Feature.enabled?(:ci_preload_runner_tags, default_enabled: :yaml)
+
+ if tags.loaded?
+ tags.map(&:name)
+ else
+ super
+ end
+ end
+
def has_tags?
tag_list.any?
end
@@ -305,8 +316,10 @@ module Ci
end
def pick_build!(build)
- if can_pick?(build)
- tick_runner_queue
+ if Feature.enabled?(:ci_reduce_queries_when_ticking_runner_queue, self, default_enabled: :yaml)
+ tick_runner_queue if matches_build?(build)
+ else
+ tick_runner_queue if can_pick?(build)
end
end
@@ -370,6 +383,13 @@ module Ci
end
end
+ # TODO: choose a better name and consider splitting this method into two
+ def matches_build?(build)
+ return false if self.ref_protected? && !build.protected?
+
+ accepting_tags?(build)
+ end
+
def accepting_tags?(build)
(run_untagged? || build.has_tags?) && (build.tag_list - tag_list).empty?
end