diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-01-24 22:00:01 +0100 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-01-25 10:49:35 +0100 |
commit | 3441b4f93bcb606313d2cdba49144afb62e9a9b8 (patch) | |
tree | c7dfc8ebecd5289a2a04b0f918aa0966df7da934 /lib/ci | |
parent | b368447cf7fbd090704e22311dde72cd293d9779 (diff) | |
download | gitlab-ce-3441b4f93bcb606313d2cdba49144afb62e9a9b8.tar.gz |
Fix picking CI builds
The conflict happens when we try to update a build,
but fail to do so due to fact that we update the same build concurrently for two different runners.
Diffstat (limited to 'lib/ci')
-rw-r--r-- | lib/ci/api/builds.rb | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/lib/ci/api/builds.rb b/lib/ci/api/builds.rb index a9da8ea7eeb..8887bba1dbe 100644 --- a/lib/ci/api/builds.rb +++ b/lib/ci/api/builds.rb @@ -23,19 +23,25 @@ module Ci new_update = current_runner.ensure_runner_queue_value - build = Ci::RegisterBuildService.new(current_runner).execute + build, valid = Ci::RegisterBuildService.new(current_runner).execute - if build - Gitlab::Metrics.add_event(:build_found, - project: build.project.path_with_namespace) + if valid + if build + Gitlab::Metrics.add_event(:build_found, + project: build.project.path_with_namespace) - present build, with: Entities::BuildDetails - else - Gitlab::Metrics.add_event(:build_not_found) + present build, with: Entities::BuildDetails + else + Gitlab::Metrics.add_event(:build_not_found) - header 'X-GitLab-Last-Update', new_update + header 'X-GitLab-Last-Update', new_update - build_not_found! + build_not_found! + end + else + # We received build that is invalid due to concurrency conflict + Gitlab::Metrics.add_event(:build_invalid) + conflict! end end |