diff options
author | Robert Speicher <robert@gitlab.com> | 2015-11-03 16:14:42 +0000 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2015-11-04 10:34:36 -0500 |
commit | 52994bb915510f7f91008097d7f8bdb3c6cd2670 (patch) | |
tree | 9468d332595109c9fc158e7fe1d6827b15e49bf3 | |
parent | 38039e3ace0ef2a474cca264f045d9518d6a49d0 (diff) | |
download | gitlab-ce-52994bb915510f7f91008097d7f8bdb3c6cd2670.tar.gz |
Merge branch 'spread-runner-last-updated-at' into 'master'
Spread out runner contacted_at updates
This is meant to prevent having too many concurrent UPDATE requests
caused by runners checking in.
See merge request !1722
-rw-r--r-- | CHANGELOG | 4 | ||||
-rw-r--r-- | lib/ci/api/helpers.rb | 4 |
2 files changed, 7 insertions, 1 deletions
diff --git a/CHANGELOG b/CHANGELOG index 0f42d26edb7..797ee2614f7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,10 @@ v 8.1.3 - Force update refs/merge-requests/X/head upon a push to the source branch of a merge request (Stan Hu) v 8.1.2 +v 8.1.3 + - Spread out runner contacted_at updates + +v 8.1.1 - Fix cloning Wiki repositories via HTTP (Stan Hu) - Add migration to remove satellites directory - Fix specific runners visibility diff --git a/lib/ci/api/helpers.rb b/lib/ci/api/helpers.rb index e602cda81d6..7e4986b6af3 100644 --- a/lib/ci/api/helpers.rb +++ b/lib/ci/api/helpers.rb @@ -16,7 +16,9 @@ module Ci end def update_runner_last_contact - if current_runner.contacted_at.nil? || Time.now - current_runner.contacted_at >= UPDATE_RUNNER_EVERY + # Use a random threshold to prevent beating DB updates + contacted_at_max_age = UPDATE_RUNNER_EVERY + Random.rand(UPDATE_RUNNER_EVERY) + if current_runner.contacted_at.nil? || Time.now - current_runner.contacted_at >= contacted_at_max_age current_runner.update_attributes(contacted_at: Time.now) end end |