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

First attempt

parent 3a906126
......@@ -16,6 +16,15 @@ module Ci
not_found! unless current_runner.active?
update_runner_info
last_update = Gitlab::Redis.with { |redis| redis.get(current_runner_redis_key)}
if params[:last_update] != ""
if :last_update == last_update
headers 'X-GitLab-Last-Update', last_update
return build_not_found!
end
end
build = Ci::RegisterBuildService.new.execute(current_runner)
if build
......@@ -26,6 +35,14 @@ module Ci
else
Gitlab::Metrics.add_event(:build_not_found)
if last_update == ""
Gitlab::Redis.with do |redis]
new_update = Time.new.inspect
redis.set(current_runner_redis_key, new_update, ex: 60.minutes)
headers 'X-GitLab-Last-Update', new_update
end
end
build_not_found!
end
end
......
......@@ -60,6 +60,9 @@ module Ci
@runner ||= Runner.find_by_token(params[:token].to_s)
end
def current_runner_redis_key
@runner_redis_key ||= "#{current_runner.token}_#{current_runner.tag_list}"
def get_runner_version_from_params
return unless params["info"].present?
attributes_for_keys(["name", "version", "revision", "platform", "architecture"], params["info"])
......
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