BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
b1c40590
Unverified
Commit
b1c40590
authored
Jan 29, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extend Runner API helpers with cache info storage
parent
dc325c67
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
5 deletions
+11
-5
runner.rb
lib/api/helpers/runner.rb
+11
-5
No files found.
lib/api/helpers/runner.rb
View file @
b1c40590
...
...
@@ -27,6 +27,8 @@ module API
end
def
update_runner_info
update_runner_info_cache
return
unless
update_runner?
current_runner
.
contacted_at
=
Time
.
now
...
...
@@ -35,13 +37,17 @@ module API
end
def
update_runner?
# Use a random threshold to prevent beating DB updates.
# It generates a distribution between [40m, 80m].
#
contacted_at_max_age
=
UPDATE_RUNNER_EVERY
+
Random
.
rand
(
UPDATE_RUNNER_EVERY
)
# Use a 1h threshold to prevent beating DB updates.
current_runner
.
contacted_at
.
nil?
||
(
Time
.
now
-
current_runner
.
contacted_at
)
>=
contacted_at_max_age
(
Time
.
now
-
current_runner
.
contacted_at
)
>=
UPDATE_RUNNER_EVERY
end
def
update_runner_info_cache
Gitlab
::
Redis
::
SharedState
.
with
do
|
redis
|
redis_key
=
"
#{
current_runner
.
runner_info_key
}
:contacted_at"
redis
.
set
(
redis_key
,
Time
.
now
)
end
end
def
validate_job!
(
job
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment