Commit b53d3ac8 authored by Stan Hu's avatar Stan Hu

Work around Ruby 2.5.3 crash when a CI job is selected

Ruby 2.5.3 in combination with Rails 5 appears to crash in development
when a CI job is selected for a runner. For some reason, the return
inside the block seems to seg fault. Let's get rid of this since
this isn't a good coding practice in any case.

Relates to https://gitlab.com/gitlab-org/gitlab-ce/issues/54281

Also see https://bugs.ruby-lang.org/issues/15325.
parent ac6673dd
......@@ -36,7 +36,7 @@ module Ci
builds = builds.with_any_tags
end
builds.find do |build|
selection = builds.find do |build|
next unless runner.can_pick?(build)
begin
......@@ -45,7 +45,7 @@ module Ci
if assign_runner!(build, params)
register_success(build)
return Result.new(build, true) # rubocop:disable Cop/AvoidReturnFromBlocks
break build
end
rescue StateMachines::InvalidTransition, ActiveRecord::StaleObjectError
# We are looping to find another build that is not conflicting
......@@ -61,6 +61,8 @@ module Ci
end
end
return Result.new(selection, true) if selection
register_failure
Result.new(nil, valid)
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