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
2b27a98d
Commit
2b27a98d
authored
Feb 28, 2017
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for Workhorse notifications
parent
859a9cd9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
6 deletions
+23
-6
app/models/ci/runner.rb
app/models/ci/runner.rb
+5
-6
changelogs/unreleased/use-redis-channel-to-post-runner-notifcations.yml
...eleased/use-redis-channel-to-post-runner-notifcations.yml
+4
-0
lib/gitlab/workhorse.rb
lib/gitlab/workhorse.rb
+14
-0
No files found.
app/models/ci/runner.rb
View file @
2b27a98d
...
@@ -127,17 +127,16 @@ module Ci
...
@@ -127,17 +127,16 @@ module Ci
def
tick_runner_queue
def
tick_runner_queue
SecureRandom
.
hex
.
tap
do
|
new_update
|
SecureRandom
.
hex
.
tap
do
|
new_update
|
Gitlab
::
Redis
.
with
do
|
redis
|
::
Gitlab
::
Workhorse
.
ensure_and_notify
(
runner_queue_key
,
new_update
,
redis
.
set
(
runner_queue_key
,
new_update
,
ex:
RUNNER_QUEUE_EXPIRY_TIME
)
expire:
RUNNER_QUEUE_EXPIRY_TIME
,
overwrite:
true
)
end
end
end
end
end
def
ensure_runner_queue_value
def
ensure_runner_queue_value
Gitlab
::
Redis
.
with
do
|
redis
|
Gitlab
::
Redis
.
with
do
|
redis
|
value
=
SecureRandom
.
hex
new_
value
=
SecureRandom
.
hex
redis
.
set
(
runner_queue_key
,
value
,
ex:
RUNNER_QUEUE_EXPIRY_TIME
,
nx:
true
)
::
Gitlab
::
Workhorse
.
ensure_and_notify
(
runner_queue_key
,
new_value
,
redis
.
get
(
runner_queue_key
)
expire:
RUNNER_QUEUE_EXPIRY_TIME
,
overwrite:
false
)
end
end
end
end
...
...
changelogs/unreleased/use-redis-channel-to-post-runner-notifcations.yml
0 → 100644
View file @
2b27a98d
---
title
:
Use redis channel to post notifications
merge_request
:
author
:
lib/gitlab/workhorse.rb
View file @
2b27a98d
...
@@ -8,6 +8,7 @@ module Gitlab
...
@@ -8,6 +8,7 @@ module Gitlab
VERSION_FILE
=
'GITLAB_WORKHORSE_VERSION'
.
freeze
VERSION_FILE
=
'GITLAB_WORKHORSE_VERSION'
.
freeze
INTERNAL_API_CONTENT_TYPE
=
'application/vnd.gitlab-workhorse+json'
.
freeze
INTERNAL_API_CONTENT_TYPE
=
'application/vnd.gitlab-workhorse+json'
.
freeze
INTERNAL_API_REQUEST_HEADER
=
'Gitlab-Workhorse-Api-Request'
.
freeze
INTERNAL_API_REQUEST_HEADER
=
'Gitlab-Workhorse-Api-Request'
.
freeze
NOTIFICATION_CHANNEL
=
'workhorse:notifications'
.
freeze
# Supposedly the effective key size for HMAC-SHA256 is 256 bits, i.e. 32
# Supposedly the effective key size for HMAC-SHA256 is 256 bits, i.e. 32
# bytes https://tools.ietf.org/html/rfc4868#section-2.6
# bytes https://tools.ietf.org/html/rfc4868#section-2.6
...
@@ -154,6 +155,19 @@ module Gitlab
...
@@ -154,6 +155,19 @@ module Gitlab
Rails
.
root
.
join
(
'.gitlab_workhorse_secret'
)
Rails
.
root
.
join
(
'.gitlab_workhorse_secret'
)
end
end
def
ensure_and_notify
(
key
,
value
,
expire:
nil
,
overwrite:
true
)
Gitlab
::
Redis
.
with
do
|
redis
|
result
=
redis
.
set
(
key
,
value
,
ex:
expire
,
nx:
!
overwrite
)
if
result
payload
=
"
#{
key
}
=
#{
value
}
"
redis
.
publish
(
RUNNER_NOTIFICATION_CHANNEL
,
payload
)
value
else
redis
.
get
(
key
)
end
end
end
protected
protected
def
encode
(
hash
)
def
encode
(
hash
)
...
...
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