summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKamil TrzciƄski <ayufan@ayufan.eu>2017-01-20 09:13:05 +0000
committerJames Lopez <james@jameslopez.es>2017-01-20 15:00:48 +0100
commit0b5c8ccd092d655ad9ee5a498f4ac434a7226c04 (patch)
tree8bdea57b7c7695dafc9422097627359743d7056f /lib
parent89bf4be8abf1482da936239f016aa5005f310db7 (diff)
downloadgitlab-ce-0b5c8ccd092d655ad9ee5a498f4ac434a7226c04.tar.gz
Merge branch '21698-redis-runner-last-build' into 'master'
Reduce DB-load for build-queues by storing last_update in Redis See merge request !8084
Diffstat (limited to 'lib')
-rw-r--r--lib/api/helpers.rb2
-rw-r--r--lib/ci/api/builds.rb9
2 files changed, 10 insertions, 1 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb
index 6b81fbf294e..49c5f0652ab 100644
--- a/lib/api/helpers.rb
+++ b/lib/api/helpers.rb
@@ -226,7 +226,7 @@ module API
end
def render_api_error!(message, status)
- error!({ 'message' => message }, status)
+ error!({ 'message' => message }, status, header)
end
def handle_api_exception(exception)
diff --git a/lib/ci/api/builds.rb b/lib/ci/api/builds.rb
index 142bce82286..c4bdef781f7 100644
--- a/lib/ci/api/builds.rb
+++ b/lib/ci/api/builds.rb
@@ -16,6 +16,13 @@ module Ci
not_found! unless current_runner.active?
update_runner_info
+ if current_runner.is_runner_queue_value_latest?(params[:last_update])
+ header 'X-GitLab-Last-Update', params[:last_update]
+ return build_not_found!
+ end
+
+ new_update = current_runner.ensure_runner_queue_value
+
build = Ci::RegisterBuildService.new.execute(current_runner)
if build
@@ -26,6 +33,8 @@ module Ci
else
Gitlab::Metrics.add_event(:build_not_found)
+ header 'X-GitLab-Last-Update', new_update
+
build_not_found!
end
end