Commit b9b9a758 authored by Stan Hu's avatar Stan Hu

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
parent 0a42c7cb
...@@ -36,7 +36,7 @@ module Ci ...@@ -36,7 +36,7 @@ module Ci
builds = builds.with_any_tags builds = builds.with_any_tags
end end
selection = builds.find do |build| builds.each do |build|
next unless runner.can_pick?(build) next unless runner.can_pick?(build)
begin begin
...@@ -45,7 +45,7 @@ module Ci ...@@ -45,7 +45,7 @@ module Ci
if assign_runner!(build, params) if assign_runner!(build, params)
register_success(build) register_success(build)
break build return Result.new(build, true)
end end
rescue StateMachines::InvalidTransition, ActiveRecord::StaleObjectError rescue StateMachines::InvalidTransition, ActiveRecord::StaleObjectError
# We are looping to find another build that is not conflicting # We are looping to find another build that is not conflicting
...@@ -61,8 +61,6 @@ module Ci ...@@ -61,8 +61,6 @@ module Ci
end end
end end
return Result.new(selection, true) if selection
register_failure register_failure
Result.new(nil, valid) Result.new(nil, valid)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment