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
c9bb2ad6
Commit
c9bb2ad6
authored
Apr 06, 2021
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move some issue after creation tasks to async job
parent
f82a9c95
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
77 additions
and
27 deletions
+77
-27
app/services/issues/create_service.rb
app/services/issues/create_service.rb
+8
-4
app/workers/new_issue_worker.rb
app/workers/new_issue_worker.rb
+7
-0
config/feature_flags/development/issue_perform_after_creation_tasks_async.yml
.../development/issue_perform_after_creation_tasks_async.yml
+8
-0
ee/app/services/ee/issues/create_service.rb
ee/app/services/ee/issues/create_service.rb
+1
-0
spec/services/issues/create_service_spec.rb
spec/services/issues/create_service_spec.rb
+26
-23
spec/workers/new_issue_worker_spec.rb
spec/workers/new_issue_worker_spec.rb
+27
-0
No files found.
app/services/issues/create_service.rb
View file @
c9bb2ad6
...
...
@@ -32,13 +32,17 @@ module Issues
end
end
# Add new items to Issues::AfterCreateService if they can be performed in Sidekiq
def
after_create
(
issue
)
add_incident_label
(
issue
)
todo_service
.
new_issue
(
issue
,
current_user
)
user_agent_detail_service
.
create
resolve_discussions_with_issue
(
issue
)
delete_milestone_total_issue_counter_cache
(
issue
.
milestone
)
track_incident_action
(
current_user
,
issue
,
:incident_created
)
if
Feature
.
disabled?
(
:issue_perform_after_creation_tasks_async
,
issue
.
project
)
Issues
::
AfterCreateService
.
new
(
issue
.
project
,
current_user
)
.
execute
(
issue
)
end
super
end
...
...
@@ -77,4 +81,4 @@ module Issues
end
end
Issues
::
CreateService
.
prepend_
if_ee
(
'EE::Issues::CreateService'
)
Issues
::
CreateService
.
prepend_
ee_mod
app/workers/new_issue_worker.rb
View file @
c9bb2ad6
...
...
@@ -14,7 +14,14 @@ class NewIssueWorker # rubocop:disable Scalability/IdempotentWorker
::
EventCreateService
.
new
.
open_issue
(
issuable
,
user
)
::
NotificationService
.
new
.
new_issue
(
issuable
,
user
)
issuable
.
create_cross_references!
(
user
)
if
Feature
.
enabled?
(
:issue_perform_after_creation_tasks_async
,
issuable
.
project
)
Issues
::
AfterCreateService
.
new
(
issuable
.
project
,
user
)
.
execute
(
issuable
)
end
end
def
issuable_class
...
...
config/feature_flags/development/issue_perform_after_creation_tasks_async.yml
0 → 100644
View file @
c9bb2ad6
---
name
:
issue_perform_after_creation_tasks_async
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/58588
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/21140
milestone
:
'
13.11'
type
:
development
group
:
group::geo
default_enabled
:
false
ee/app/services/ee/issues/create_service.rb
View file @
c9bb2ad6
...
...
@@ -31,6 +31,7 @@ module EE
private
def
add_issue_sla
(
issue
)
return
if
::
Feature
.
enabled?
(
:issue_perform_after_creation_tasks_async
,
issue
.
project
)
return
unless
issue
.
sla_available?
::
IncidentManagement
::
Incidents
::
CreateSlaService
.
new
(
issue
,
current_user
).
execute
...
...
spec/services/issues/create_service_spec.rb
View file @
c9bb2ad6
...
...
@@ -3,6 +3,8 @@
require
'spec_helper'
RSpec
.
describe
Issues
::
CreateService
do
include
AfterNextHelpers
let_it_be_with_reload
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
...
...
@@ -64,7 +66,6 @@ RSpec.describe Issues::CreateService do
it_behaves_like
'incident issue'
it_behaves_like
'has incident label'
it_behaves_like
'an incident management tracked event'
,
:incident_management_incident_created
it
'does create an incident label'
do
expect
{
subject
}
...
...
@@ -112,26 +113,36 @@ RSpec.describe Issues::CreateService do
end
end
it
'creates a pending todo for new assignee'
do
attributes
=
{
project:
project
,
author:
user
,
user:
assignee
,
target_id:
issue
.
id
,
target_type:
issue
.
class
.
name
,
action:
Todo
::
ASSIGNED
,
state: :pending
}
expect
(
Todo
.
where
(
attributes
).
count
).
to
eq
1
end
it
'moves the issue to the end, in an asynchronous worker'
do
expect
(
IssuePlacementWorker
).
to
receive
(
:perform_async
).
with
(
be_nil
,
Integer
)
described_class
.
new
(
project
,
user
,
opts
).
execute
end
context
'with issue_perform_after_creation_tasks_async feature disabled'
do
before
do
stub_feature_flags
(
issue_perform_after_creation_tasks_async:
false
)
end
it
'calls Issues::AfterCreateService'
do
expect_next
(
::
Issues
::
AfterCreateService
,
project
,
user
).
to
receive
(
:execute
)
described_class
.
new
(
project
,
user
,
opts
).
execute
end
end
context
'with issue_perform_after_creation_tasks_async feature enabled'
do
before
do
stub_feature_flags
(
issue_perform_after_creation_tasks_async:
true
)
end
it
'does not call Issues::AfterCreateService'
do
expect
(
::
Issues
::
AfterCreateService
).
not_to
receive
(
:new
)
described_class
.
new
(
project
,
user
,
opts
).
execute
end
end
context
'when label belongs to project group'
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:group_labels
)
{
create_pair
(
:group_label
,
group:
group
)
}
...
...
@@ -279,14 +290,6 @@ RSpec.describe Issues::CreateService do
end
end
it
'deletes milestone issues count cache'
do
expect_next_instance_of
(
Milestones
::
IssuesCountService
,
milestone
)
do
|
service
|
expect
(
service
).
to
receive
(
:delete_cache
).
and_call_original
end
issue
end
it
'schedules a namespace onboarding create action worker'
do
expect
(
Namespaces
::
OnboardingIssueCreatedWorker
).
to
receive
(
:perform_async
).
with
(
project
.
namespace
.
id
)
...
...
spec/workers/new_issue_worker_spec.rb
View file @
c9bb2ad6
...
...
@@ -3,6 +3,8 @@
require
'spec_helper'
RSpec
.
describe
NewIssueWorker
do
include
AfterNextHelpers
describe
'#perform'
do
let
(
:worker
)
{
described_class
.
new
}
...
...
@@ -80,6 +82,31 @@ RSpec.describe NewIssueWorker do
worker
.
perform
(
issue
.
id
,
user
.
id
)
end
context
'with issue_perform_after_creation_tasks_async feature disabled'
do
before
do
stub_feature_flags
(
issue_perform_after_creation_tasks_async:
false
)
end
it
'does not call Issues::AfterCreateService'
do
expect
(
::
Issues
::
AfterCreateService
).
not_to
receive
(
:execute
)
worker
.
perform
(
issue
.
id
,
user
.
id
)
end
end
context
'with issue_perform_after_creation_tasks_async feature enabled'
do
before
do
stub_feature_flags
(
issue_perform_after_creation_tasks_async:
true
)
end
it
'calls Issues::AfterCreateService'
do
expect_next
(
::
Issues
::
AfterCreateService
)
.
to
receive
(
:execute
)
worker
.
perform
(
issue
.
id
,
user
.
id
)
end
end
end
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