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
667d44c2
Commit
667d44c2
authored
Apr 11, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix high CPU usage when PostReceive receives refs/merge-requests/<id>
parent
986b4a54
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
5 deletions
+41
-5
CHANGELOG
CHANGELOG
+1
-0
app/workers/post_receive.rb
app/workers/post_receive.rb
+1
-1
spec/workers/post_receive_spec.rb
spec/workers/post_receive_spec.rb
+39
-4
No files found.
CHANGELOG
View file @
667d44c2
...
@@ -24,6 +24,7 @@ v 8.7.0 (unreleased)
...
@@ -24,6 +24,7 @@ v 8.7.0 (unreleased)
- API: Ability to filter milestones by state `active` and `closed` (Robert Schilling)
- API: Ability to filter milestones by state `active` and `closed` (Robert Schilling)
- Implement 'Groups View' as an option for dashboard preferences !3379 (Elias W.)
- Implement 'Groups View' as an option for dashboard preferences !3379 (Elias W.)
- Better errors handling when creating milestones inside groups
- Better errors handling when creating milestones inside groups
- Fix high CPU usage when PostReceive receives refs/merge-requests/<id>
- Implement 'TODOs View' as an option for dashboard preferences !3379 (Elias W.)
- Implement 'TODOs View' as an option for dashboard preferences !3379 (Elias W.)
- Gracefully handle notes on deleted commits in merge requests (Stan Hu)
- Gracefully handle notes on deleted commits in merge requests (Stan Hu)
- Fix creation of merge requests for orphaned branches (Stan Hu)
- Fix creation of merge requests for orphaned branches (Stan Hu)
...
...
app/workers/post_receive.rb
View file @
667d44c2
...
@@ -40,7 +40,7 @@ class PostReceive
...
@@ -40,7 +40,7 @@ class PostReceive
if
Gitlab
::
Git
.
tag_ref?
(
ref
)
if
Gitlab
::
Git
.
tag_ref?
(
ref
)
GitTagPushService
.
new
.
execute
(
post_received
.
project
,
@user
,
oldrev
,
newrev
,
ref
)
GitTagPushService
.
new
.
execute
(
post_received
.
project
,
@user
,
oldrev
,
newrev
,
ref
)
els
e
els
if
Gitlab
::
Git
.
branch_ref?
(
ref
)
GitPushService
.
new
(
post_received
.
project
,
@user
,
oldrev:
oldrev
,
newrev:
newrev
,
ref:
ref
).
execute
GitPushService
.
new
(
post_received
.
project
,
@user
,
oldrev:
oldrev
,
newrev:
newrev
,
ref:
ref
).
execute
end
end
end
end
...
...
spec/workers/post_receive_spec.rb
View file @
667d44c2
...
@@ -4,6 +4,9 @@ describe PostReceive do
...
@@ -4,6 +4,9 @@ describe PostReceive do
let
(
:changes
)
{
"123456 789012 refs/heads/tést
\n
654321 210987 refs/tags/tag"
}
let
(
:changes
)
{
"123456 789012 refs/heads/tést
\n
654321 210987 refs/tags/tag"
}
let
(
:wrongly_encoded_changes
)
{
changes
.
encode
(
"ISO-8859-1"
).
force_encoding
(
"UTF-8"
)
}
let
(
:wrongly_encoded_changes
)
{
changes
.
encode
(
"ISO-8859-1"
).
force_encoding
(
"UTF-8"
)
}
let
(
:base64_changes
)
{
Base64
.
encode64
(
wrongly_encoded_changes
)
}
let
(
:base64_changes
)
{
Base64
.
encode64
(
wrongly_encoded_changes
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:key
)
{
create
(
:key
,
user:
project
.
owner
)
}
let
(
:key_id
)
{
key
.
shell_id
}
context
"as a resque worker"
do
context
"as a resque worker"
do
it
"reponds to #perform"
do
it
"reponds to #perform"
do
...
@@ -11,11 +14,43 @@ describe PostReceive do
...
@@ -11,11 +14,43 @@ describe PostReceive do
end
end
end
end
context
"webhook"
do
describe
"#process_project_changes"
do
let
(
:project
)
{
create
(
:project
)
}
before
do
let
(
:key
)
{
create
(
:key
,
user:
project
.
owner
)
}
allow_any_instance_of
(
Gitlab
::
GitPostReceive
).
to
receive
(
:identify
).
and_return
(
project
.
owner
)
let
(
:key_id
)
{
key
.
shell_id
}
end
context
"branches"
do
let
(
:changes
)
{
"123456 789012 refs/heads/tést"
}
it
"should call GitTagPushService"
do
expect_any_instance_of
(
GitPushService
).
to
receive
(
:execute
).
and_return
(
true
)
expect_any_instance_of
(
GitTagPushService
).
not_to
receive
(
:execute
)
PostReceive
.
new
.
perform
(
pwd
(
project
),
key_id
,
base64_changes
)
end
end
context
"tags"
do
let
(
:changes
)
{
"123456 789012 refs/tags/tag"
}
it
"should call GitTagPushService"
do
expect_any_instance_of
(
GitPushService
).
not_to
receive
(
:execute
)
expect_any_instance_of
(
GitTagPushService
).
to
receive
(
:execute
).
and_return
(
true
)
PostReceive
.
new
.
perform
(
pwd
(
project
),
key_id
,
base64_changes
)
end
end
context
"merge-requests"
do
let
(
:changes
)
{
"123456 789012 refs/merge-requests/123"
}
it
"should not call any of the services"
do
expect_any_instance_of
(
GitPushService
).
not_to
receive
(
:execute
)
expect_any_instance_of
(
GitTagPushService
).
not_to
receive
(
:execute
)
PostReceive
.
new
.
perform
(
pwd
(
project
),
key_id
,
base64_changes
)
end
end
end
context
"webhook"
do
it
"fetches the correct project"
do
it
"fetches the correct project"
do
expect
(
Project
).
to
receive
(
:find_with_namespace
).
with
(
project
.
path_with_namespace
).
and_return
(
project
)
expect
(
Project
).
to
receive
(
:find_with_namespace
).
with
(
project
.
path_with_namespace
).
and_return
(
project
)
PostReceive
.
new
.
perform
(
pwd
(
project
),
key_id
,
base64_changes
)
PostReceive
.
new
.
perform
(
pwd
(
project
),
key_id
,
base64_changes
)
...
...
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