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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
08e31875
Commit
08e31875
authored
Sep 27, 2016
by
Kamil Trzcinski
Committed by
Grzegorz Bizon
Oct 03, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update runner version only when updating contacted_at
parent
71345998
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
15 deletions
+12
-15
CHANGELOG
CHANGELOG
+1
-0
app/models/ci/runner.rb
app/models/ci/runner.rb
+1
-1
lib/ci/api/builds.rb
lib/ci/api/builds.rb
+3
-3
lib/ci/api/helpers.rb
lib/ci/api/helpers.rb
+7
-11
No files found.
CHANGELOG
View file @
08e31875
Please view this file on the master branch, on stable branches it's out of date.
Please view this file on the master branch, on stable branches it's out of date.
v 8.13.0 (unreleased)
v 8.13.0 (unreleased)
- Update runner version only when updating contacted_at
- Add link from system note to compare with previous version
- Add link from system note to compare with previous version
- Use gitlab-shell v3.6.2 (GIT TRACE logging)
- Use gitlab-shell v3.6.2 (GIT TRACE logging)
- Fix centering of custom header logos (Ashley Dumaine)
- Fix centering of custom header logos (Ashley Dumaine)
...
...
app/models/ci/runner.rb
View file @
08e31875
...
@@ -2,7 +2,7 @@ module Ci
...
@@ -2,7 +2,7 @@ module Ci
class
Runner
<
ActiveRecord
::
Base
class
Runner
<
ActiveRecord
::
Base
extend
Ci
::
Model
extend
Ci
::
Model
LAST_CONTACT_TIME
=
2
.
hours
.
ago
LAST_CONTACT_TIME
=
1
.
hour
.
ago
AVAILABLE_SCOPES
=
%w[specific shared active paused online]
AVAILABLE_SCOPES
=
%w[specific shared active paused online]
FORM_EDITABLE
=
%i[description tag_list active run_untagged locked]
FORM_EDITABLE
=
%i[description tag_list active run_untagged locked]
...
...
lib/ci/api/builds.rb
View file @
08e31875
...
@@ -12,10 +12,9 @@ module Ci
...
@@ -12,10 +12,9 @@ module Ci
# POST /builds/register
# POST /builds/register
post
"register"
do
post
"register"
do
authenticate_runner!
authenticate_runner!
update_runner_last_contact
(
save:
false
)
update_runner_info
required_attributes!
[
:token
]
required_attributes!
[
:token
]
not_found!
unless
current_runner
.
active?
not_found!
unless
current_runner
.
active?
update_runner_info
build
=
Ci
::
RegisterBuildService
.
new
.
execute
(
current_runner
)
build
=
Ci
::
RegisterBuildService
.
new
.
execute
(
current_runner
)
...
@@ -41,10 +40,11 @@ module Ci
...
@@ -41,10 +40,11 @@ module Ci
# PUT /builds/:id
# PUT /builds/:id
put
":id"
do
put
":id"
do
authenticate_runner!
authenticate_runner!
update_runner_last_contact
build
=
Ci
::
Build
.
where
(
runner_id:
current_runner
.
id
).
running
.
find
(
params
[
:id
])
build
=
Ci
::
Build
.
where
(
runner_id:
current_runner
.
id
).
running
.
find
(
params
[
:id
])
forbidden!
(
'Build has been erased!'
)
if
build
.
erased?
forbidden!
(
'Build has been erased!'
)
if
build
.
erased?
update_runner_info
build
.
update_attributes
(
trace:
params
[
:trace
])
if
params
[
:trace
]
build
.
update_attributes
(
trace:
params
[
:trace
])
if
params
[
:trace
]
Gitlab
::
Metrics
.
add_event
(
:update_build
,
Gitlab
::
Metrics
.
add_event
(
:update_build
,
...
...
lib/ci/api/helpers.rb
View file @
08e31875
...
@@ -3,7 +3,7 @@ module Ci
...
@@ -3,7 +3,7 @@ module Ci
module
Helpers
module
Helpers
BUILD_TOKEN_HEADER
=
"HTTP_BUILD_TOKEN"
BUILD_TOKEN_HEADER
=
"HTTP_BUILD_TOKEN"
BUILD_TOKEN_PARAM
=
:token
BUILD_TOKEN_PARAM
=
:token
UPDATE_RUNNER_EVERY
=
4
0
*
60
UPDATE_RUNNER_EVERY
=
1
0
*
60
def
authenticate_runners!
def
authenticate_runners!
forbidden!
unless
runner_registration_token_valid?
forbidden!
unless
runner_registration_token_valid?
...
@@ -30,14 +30,15 @@ module Ci
...
@@ -30,14 +30,15 @@ module Ci
token
&&
(
build
.
valid_token?
(
token
)
||
build
.
project
.
valid_runners_token?
(
token
))
token
&&
(
build
.
valid_token?
(
token
)
||
build
.
project
.
valid_runners_token?
(
token
))
end
end
def
update_runner_
last_contact
(
save:
true
)
def
update_runner_
info
# Use a random threshold to prevent beating DB updates
# Use a random threshold to prevent beating DB updates
# it generates a distribution between: [40m, 80m]
# it generates a distribution between: [40m, 80m]
contacted_at_max_age
=
UPDATE_RUNNER_EVERY
+
Random
.
rand
(
UPDATE_RUNNER_EVERY
)
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
return
unless
current_runner
.
contacted_at
.
nil?
||
Time
.
now
-
current_runner
.
contacted_at
>=
contacted_at_max_age
current_runner
.
contacted_at
=
Time
.
now
current_runner
.
save
if
current_runner
.
changed?
&&
save
current_runner
.
contacted_at
=
Time
.
now
end
current_runner
.
assign_attributes
(
get_runner_version_from_params
)
current_runner
.
save
if
current_runner
.
changed?
end
end
def
build_not_found!
def
build_not_found!
...
@@ -57,11 +58,6 @@ module Ci
...
@@ -57,11 +58,6 @@ module Ci
attributes_for_keys
([
"name"
,
"version"
,
"revision"
,
"platform"
,
"architecture"
],
params
[
"info"
])
attributes_for_keys
([
"name"
,
"version"
,
"revision"
,
"platform"
,
"architecture"
],
params
[
"info"
])
end
end
def
update_runner_info
current_runner
.
assign_attributes
(
get_runner_version_from_params
)
current_runner
.
save
if
current_runner
.
changed?
end
def
max_artifacts_size
def
max_artifacts_size
current_application_settings
.
max_artifacts_size
.
megabytes
.
to_i
current_application_settings
.
max_artifacts_size
.
megabytes
.
to_i
end
end
...
...
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