summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-11-22 22:21:27 -0800
committerStan Hu <stanhu@gmail.com>2018-11-22 22:25:24 -0800
commitb9b9a75849cec9c081bd130a90eaa1204d45b4cd (patch)
tree048767afefc6993c0be86731289c0363c1b3cb0d
parent0a42c7cbaae51466a67a4011859726c29bc24da4 (diff)
downloadgitlab-ce-b9b9a75849cec9c081bd130a90eaa1204d45b4cd.tar.gz
Clean up fix for RegisterJobServicesh-register-ci-job-service-improve
Prefer `each` to `find` since the former does the same thing except doesn't add the extra delegation step that may be causing the binding_of_caller gem issues. Relates to https://gitlab.com/gitlab-org/gitlab-ce/issues/54281#note_119494004
-rw-r--r--app/services/ci/register_job_service.rb6
1 files changed, 2 insertions, 4 deletions
diff --git a/app/services/ci/register_job_service.rb b/app/services/ci/register_job_service.rb
index 2abc4a67dd6..13321b2682e 100644
--- a/app/services/ci/register_job_service.rb
+++ b/app/services/ci/register_job_service.rb
@@ -36,7 +36,7 @@ module Ci
builds = builds.with_any_tags
end
- selection = builds.find do |build|
+ builds.each do |build|
next unless runner.can_pick?(build)
begin
@@ -45,7 +45,7 @@ module Ci
if assign_runner!(build, params)
register_success(build)
- break build
+ return Result.new(build, true)
end
rescue StateMachines::InvalidTransition, ActiveRecord::StaleObjectError
# We are looping to find another build that is not conflicting
@@ -61,8 +61,6 @@ module Ci
end
end
- return Result.new(selection, true) if selection
-
register_failure
Result.new(nil, valid)
end