diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /app/services/ci/register_job_service.rb | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'app/services/ci/register_job_service.rb')
-rw-r--r-- | app/services/ci/register_job_service.rb | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/app/services/ci/register_job_service.rb b/app/services/ci/register_job_service.rb index 3797ea1d96c..04d620d1d38 100644 --- a/app/services/ci/register_job_service.rb +++ b/app/services/ci/register_job_service.rb @@ -107,23 +107,15 @@ module Ci build.runner_id = runner.id build.runner_session_attributes = params[:session] if params[:session].present? - unless build.has_valid_build_dependencies? - build.drop!(:missing_dependency_failure) - return false - end - - unless build.supported_runner?(params.dig(:info, :features)) - build.drop!(:runner_unsupported) - return false - end + failure_reason, _ = pre_assign_runner_checks.find { |_, check| check.call(build, params) } - if build.archived? - build.drop!(:archived_failure) - return false + if failure_reason + build.drop!(failure_reason) + else + build.run! end - build.run! - true + !failure_reason end def scheduler_failure!(build) @@ -238,6 +230,14 @@ module Ci def job_queue_duration_seconds @job_queue_duration_seconds ||= Gitlab::Metrics.histogram(:job_queue_duration_seconds, 'Request handling execution time', {}, JOB_QUEUE_DURATION_SECONDS_BUCKETS) end + + def pre_assign_runner_checks + { + missing_dependency_failure: -> (build, _) { !build.has_valid_build_dependencies? }, + runner_unsupported: -> (build, params) { !build.supported_runner?(params.dig(:info, :features)) }, + archived_failure: -> (build, _) { build.archived? } + } + end end end |