Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
b1c40590
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
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
5 deletions
+11
-5
lib/api/helpers/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