summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKim "BKC" Carlbäcker <kim.carlbacker@gmail.com>2016-12-16 16:39:40 +0100
committerKim "BKC" Carlbäcker <kim.carlbacker@gmail.com>2016-12-16 16:39:40 +0100
commitb0b05f811cc11472798661de713e2564cae2e9d5 (patch)
tree01f7a062fe7d96bd3e607b6eacdcf73dc94c2b04
parentfb713071db822cd5946e201d749ebee42ecbae0d (diff)
downloadgitlab-ce-b0b05f811cc11472798661de713e2564cae2e9d5.tar.gz
Make expire-time a constant, correct function in Service
-rw-r--r--app/models/ci/runner.rb5
-rw-r--r--app/services/ci/update_build_queue_service.rb2
2 files changed, 4 insertions, 3 deletions
diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb
index d5b5a84d477..850be67d98f 100644
--- a/app/models/ci/runner.rb
+++ b/app/models/ci/runner.rb
@@ -2,6 +2,7 @@ module Ci
class Runner < ActiveRecord::Base
extend Ci::Model
+ LAST_UPDATE_EXPIRE_TIME = 60.minutes
LAST_CONTACT_TIME = 1.hour.ago
AVAILABLE_SCOPES = %w[specific shared active paused online]
FORM_EDITABLE = %i[description tag_list active run_untagged locked]
@@ -126,14 +127,14 @@ module Ci
def tick_runner_queue
new_update = Time.new.inspect
- Gitlab::Redis.with { |redis| redis.set(runner_queue_key, new_update, ex: 60.minutes) }
+ Gitlab::Redis.with { |redis| redis.set(runner_queue_key, new_update, ex: LAST_UPDATE_EXPIRE_TIME) }
new_update
end
def ensure_runner_queue_value
Gitlab::Redis.with do |redis|
value = Time.new.inspect
- redis.set(runner_queue_key, value, ex: 60.minutes, nx: true)
+ redis.set(runner_queue_key, value, ex: LAST_UPDATE_EXPIRE_TIME, nx: true)
redis.get(runner_queue_key)
end
end
diff --git a/app/services/ci/update_build_queue_service.rb b/app/services/ci/update_build_queue_service.rb
index dd1097f5dbe..b324863feef 100644
--- a/app/services/ci/update_build_queue_service.rb
+++ b/app/services/ci/update_build_queue_service.rb
@@ -3,7 +3,7 @@ module Ci
def execute(build)
build.project.runners.select do |runner|
if runner.can_pick?(build)
- runner.tick_update
+ runner.tick_runner_queue
end
end
end