Commit a6ab8a34 authored by Kim "BKC" Carlbäcker's avatar Kim "BKC" Carlbäcker

Add BuildQueueWorker for injecting redis-keys

parent afea2df1
......@@ -81,6 +81,12 @@ module Ci
end
state_machine :status do
after_transition any => [:pending] do |build|
build.run_after_commit do
BuildQueueWorker.perform_async(id)
end
end
after_transition pending: :running do |build|
build.run_after_commit do
BuildHooksWorker.perform_async(id)
......
class BuildQueueWorker
include Sidekiq::Worker
include BuildQueue
def perform(build_id)
Ci::Build.find_by(id: build_id).try do |build|
project.runners.select do |runner|
if runner.can_pick?(build)
# Inject last_update into Redis
Gitlab::Redis.with do |redis]
new_update = Time.new.inspect
redis.set(current_runner_redis_key, new_update, ex: 60.minutes)
end
end
end
end
end
end
......@@ -62,6 +62,7 @@ module Ci
def current_runner_redis_key
@runner_redis_key ||= "#{current_runner.token}_#{current_runner.tag_list}"
end
def get_runner_version_from_params
return unless params["info"].present?
......
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