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
811addf2
Commit
811addf2
authored
Dec 16, 2016
by
Kim "BKC" Carlbäcker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#NamingThings
parent
a20681c0
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
16 deletions
+21
-16
app/models/ci/runner.rb
app/models/ci/runner.rb
+16
-5
app/services/ci/update_build_queue_service.rb
app/services/ci/update_build_queue_service.rb
+0
-1
app/workers/build_queue_worker.rb
app/workers/build_queue_worker.rb
+1
-2
lib/ci/api/builds.rb
lib/ci/api/builds.rb
+4
-8
No files found.
app/models/ci/runner.rb
View file @
811addf2
...
...
@@ -124,19 +124,30 @@ module Ci
]
end
def
tick_
updat
e
def
tick_
runner_queu
e
new_update
=
Time
.
new
.
inspect
Gitlab
::
Redis
.
with
{
|
redis
|
redis
.
set
(
r
edis
_key
,
new_update
,
ex:
60
.
minutes
)
}
Gitlab
::
Redis
.
with
{
|
redis
|
redis
.
set
(
r
unner_queue
_key
,
new_update
,
ex:
60
.
minutes
)
}
new_update
end
def
last_build_queue_update
Gitlab
::
Redis
.
with
{
|
redis
|
redis
.
get
(
redis_key
)
}
def
ensure_runner_queue_value
Gitlab
::
Redis
.
with
do
|
redis
|
value
=
redis
.
get
(
runner_queue_key
)
if
value
==
""
value
=
Time
.
new
.
inspect
redis
.
set
(
runner_queue_key
,
value
,
ex:
60
.
minutes
)
end
value
end
end
def
is_runner_queue_value_latest?
(
value
)
ensure_runner_queue_value
==
value
if
value
.
present?
end
private
def
r
edis
_key
def
r
unner_queue
_key
"runner:build_queue:
#{
self
.
id
}
"
end
...
...
app/services/ci/update_build_queue_service.rb
View file @
811addf2
module
Ci
class
UpdateBuildQueueService
<
BaseService
def
execute
(
build
)
build
.
project
.
runners
.
select
do
|
runner
|
if
runner
.
can_pick?
(
build
)
...
...
app/workers/build_queue_worker.rb
View file @
811addf2
...
...
@@ -4,8 +4,7 @@ class BuildQueueWorker
def
perform
(
build_id
)
Ci
::
Build
.
find_by
(
id:
build_id
).
try
do
|
build
|
UpdateBuildQueueService
.
new
(
build
)
UpdateBuildQueueService
.
execute
(
build
)
end
end
end
lib/ci/api/builds.rb
View file @
811addf2
...
...
@@ -16,14 +16,10 @@ module Ci
not_found!
unless
current_runner
.
active?
update_runner_info
last_update
=
current_runner
.
last_build_queue_update
if
params
[
:last_update
].
present?
if
params
[
:last_update
]
==
last_update
headers
'X-GitLab-Last-Update'
,
last_update
if
current_runner
.
is_runner_queue_value_latest?
(
params
[
:last_update
])
headers
'X-GitLab-Last-Update'
,
params
[
:last_update
]
return
build_not_found!
end
end
build
=
Ci
::
RegisterBuildService
.
new
.
execute
(
current_runner
)
...
...
@@ -35,7 +31,7 @@ module Ci
else
Gitlab
::
Metrics
.
add_event
(
:build_not_found
)
new_update
=
current_runner
.
tick_updat
e
new_update
=
current_runner
.
ensure_runner_queue_valu
e
headers
'X-GitLab-Last-Update'
,
new_update
build_not_found!
...
...
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