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
9a8e4863
Commit
9a8e4863
authored
Oct 03, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract method that checks if ci runner needs update
parent
08e31875
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
4 deletions
+11
-4
lib/ci/api/helpers.rb
lib/ci/api/helpers.rb
+11
-4
No files found.
lib/ci/api/helpers.rb
View file @
9a8e4863
...
...
@@ -31,16 +31,23 @@ module Ci
end
def
update_runner_info
# 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
)
return
unless
current_runner
.
contacted_at
.
nil?
||
Time
.
now
-
current_runner
.
contacted_at
>=
contacted_at_max_age
return
unless
update_runner?
current_runner
.
contacted_at
=
Time
.
now
current_runner
.
assign_attributes
(
get_runner_version_from_params
)
current_runner
.
save
if
current_runner
.
changed?
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
)
current_runner
.
contacted_at
.
nil?
||
(
Time
.
now
-
current_runner
.
contacted_at
)
>=
contacted_at_max_age
end
def
build_not_found!
if
headers
[
'User-Agent'
].
match
(
/gitlab-ci-multi-runner \d+\.\d+\.\d+(~beta\.\d+\.g[0-9a-f]+)? /
)
no_content!
...
...
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