From b9b9a75849cec9c081bd130a90eaa1204d45b4cd Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Thu, 22 Nov 2018 22:21:27 -0800 Subject: [PATCH] Clean up fix for RegisterJobService 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 --- app/services/ci/register_job_service.rb | 6 ++---- 1 file 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 -- GitLab