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
Jérome Perrin
gitlab-ce
Commits
e1795443
Commit
e1795443
authored
Dec 15, 2016
by
Kim "BKC" Carlbäcker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move redis-logic into Ci::Runner
parent
771dd68c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
12 deletions
+19
-12
app/models/ci/runner.rb
app/models/ci/runner.rb
+16
-0
lib/ci/api/builds.rb
lib/ci/api/builds.rb
+3
-8
lib/ci/api/helpers.rb
lib/ci/api/helpers.rb
+0
-4
No files found.
app/models/ci/runner.rb
View file @
e1795443
...
...
@@ -21,6 +21,8 @@ module Ci
scope
:online
,
->
()
{
where
(
'contacted_at > ?'
,
LAST_CONTACT_TIME
)
}
scope
:ordered
,
->
()
{
order
(
id: :desc
)
}
after_save
:tick_update
scope
:owned_or_shared
,
->
(
project_id
)
do
joins
(
'LEFT JOIN ci_runner_projects ON ci_runner_projects.runner_id = ci_runners.id'
)
.
where
(
"ci_runner_projects.gl_project_id = :project_id OR ci_runners.is_shared = true"
,
project_id:
project_id
)
...
...
@@ -122,8 +124,22 @@ module Ci
]
end
def
tick_update
new_update
=
Time
.
new
.
inspect
Gitlab
::
Redis
.
with
{
|
redis
|
redis
.
set
(
redis_key
,
new_update
,
ex:
60
.
minutes
)
}
new_update
end
def
last_build_queue_update
Gitlab
::
Redis
.
with
{
|
redis
|
redis
.
get
(
redis_key
)
}
end
private
def
redis_key
"runner:build_queue:
#{
self
.
id
}
"
end
def
tag_constraints
unless
has_tags?
||
run_untagged?
errors
.
add
(
:tags_list
,
...
...
lib/ci/api/builds.rb
View file @
e1795443
...
...
@@ -16,7 +16,7 @@ module Ci
not_found!
unless
current_runner
.
active?
update_runner_info
last_update
=
Gitlab
::
Redis
.
with
{
|
redis
|
redis
.
get
(
current_runner_redis_key
)}
last_update
=
current_runner
.
last_build_queue_update
if
params
[
:last_update
].
present?
if
params
[
:last_update
]
==
last_update
...
...
@@ -35,13 +35,8 @@ module Ci
else
Gitlab
::
Metrics
.
add_event
(
:build_not_found
)
if
last_update
==
""
Gitlab
::
Redis
.
with
do
|
redis
|
new_update
=
Time
.
new
.
inspect
redis
.
set
(
current_runner_redis_key
,
new_update
,
ex:
60
.
minutes
)
headers
'X-GitLab-Last-Update'
,
new_update
end
end
new_update
=
current_runner
.
tick_update
headers
'X-GitLab-Last-Update'
,
new_update
build_not_found!
end
...
...
lib/ci/api/helpers.rb
View file @
e1795443
...
...
@@ -60,10 +60,6 @@ module Ci
@runner
||=
Runner
.
find_by_token
(
params
[
:token
].
to_s
)
end
def
current_runner_redis_key
@runner_redis_key
||=
"
#{
current_runner
.
token
}
_
#{
current_runner
.
tag_list
}
"
end
def
get_runner_version_from_params
return
unless
params
[
"info"
].
present?
attributes_for_keys
([
"name"
,
"version"
,
"revision"
,
"platform"
,
"architecture"
],
params
[
"info"
])
...
...
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