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
f7a81d88
Commit
f7a81d88
authored
May 26, 2021
by
Vitali Tatarintev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unused ProcessAlertWorker
Changelog: changed
parent
d7257cf6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
0 additions
and
154 deletions
+0
-154
app/workers/all_queues.yml
app/workers/all_queues.yml
+0
-9
app/workers/incident_management/process_alert_worker.rb
app/workers/incident_management/process_alert_worker.rb
+0
-56
spec/workers/every_sidekiq_worker_spec.rb
spec/workers/every_sidekiq_worker_spec.rb
+0
-1
spec/workers/incident_management/process_alert_worker_spec.rb
.../workers/incident_management/process_alert_worker_spec.rb
+0
-88
No files found.
app/workers/all_queues.yml
View file @
f7a81d88
...
...
@@ -1078,15 +1078,6 @@
:weight:
2
:idempotent:
:tags: []
-
:name: incident_management:incident_management_process_alert
:worker_name: IncidentManagement::ProcessAlertWorker
:feature_category: :incident_management
:has_external_dependencies:
:urgency: :low
:resource_boundary: :unknown
:weight:
2
:idempotent:
:tags: []
-
:name: incident_management:incident_management_process_alert_worker_v2
:worker_name: IncidentManagement::ProcessAlertWorkerV2
:feature_category: :incident_management
...
...
app/workers/incident_management/process_alert_worker.rb
deleted
100644 → 0
View file @
d7257cf6
# frozen_string_literal: true
module
IncidentManagement
class
ProcessAlertWorker
# rubocop:disable Scalability/IdempotentWorker
include
ApplicationWorker
sidekiq_options
retry:
3
queue_namespace
:incident_management
feature_category
:incident_management
# `project_id` and `alert_payload` are deprecated and can be removed
# starting from 14.0 release
# https://gitlab.com/gitlab-org/gitlab/-/issues/224500
#
# This worker is not scheduled anymore since
# https://gitlab.com/gitlab-org/gitlab/-/merge_requests/60285
# and will be removed completely via
# https://gitlab.com/gitlab-org/gitlab/-/issues/224500
# in 14.0.
def
perform
(
_project_id
=
nil
,
_alert_payload
=
nil
,
alert_id
=
nil
)
return
unless
alert_id
alert
=
find_alert
(
alert_id
)
return
unless
alert
result
=
create_issue_for
(
alert
)
return
if
result
.
success?
log_warning
(
alert
,
result
)
end
private
def
find_alert
(
alert_id
)
AlertManagement
::
Alert
.
find_by_id
(
alert_id
)
end
def
create_issue_for
(
alert
)
AlertManagement
::
CreateAlertIssueService
.
new
(
alert
,
User
.
alert_bot
)
.
execute
end
def
log_warning
(
alert
,
result
)
issue_id
=
result
.
payload
[
:issue
]
&
.
id
Gitlab
::
AppLogger
.
warn
(
message:
'Cannot process an Incident'
,
issue_id:
issue_id
,
alert_id:
alert
.
id
,
errors:
result
.
message
)
end
end
end
spec/workers/every_sidekiq_worker_spec.rb
View file @
f7a81d88
...
...
@@ -306,7 +306,6 @@ RSpec.describe 'Every Sidekiq worker' do
'IncidentManagement::OncallRotations::PersistAllRotationsShiftsJob'
=>
3
,
'IncidentManagement::OncallRotations::PersistShiftsJob'
=>
3
,
'IncidentManagement::PagerDuty::ProcessIncidentWorker'
=>
3
,
'IncidentManagement::ProcessAlertWorker'
=>
3
,
'IncidentManagement::ProcessPrometheusAlertWorker'
=>
3
,
'InvalidGpgSignatureUpdateWorker'
=>
3
,
'IrkerWorker'
=>
3
,
...
...
spec/workers/incident_management/process_alert_worker_spec.rb
deleted
100644 → 0
View file @
d7257cf6
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
IncidentManagement
::
ProcessAlertWorker
do
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:settings
)
{
create
(
:project_incident_management_setting
,
project:
project
,
create_issue:
true
)
}
describe
'#perform'
do
let_it_be
(
:started_at
)
{
Time
.
now
.
rfc3339
}
let_it_be
(
:payload
)
{
{
'title'
=>
'title'
,
'start_time'
=>
started_at
}
}
let_it_be
(
:alert
)
{
create
(
:alert_management_alert
,
project:
project
,
payload:
payload
,
started_at:
started_at
)
}
let
(
:created_issue
)
{
Issue
.
last!
}
subject
{
described_class
.
new
.
perform
(
nil
,
nil
,
alert
.
id
)
}
before
do
allow
(
Gitlab
::
AppLogger
).
to
receive
(
:warn
).
and_call_original
allow
(
AlertManagement
::
CreateAlertIssueService
)
.
to
receive
(
:new
).
with
(
alert
,
User
.
alert_bot
)
.
and_call_original
end
shared_examples
'creates issue successfully'
do
it
'creates an issue'
do
expect
(
AlertManagement
::
CreateAlertIssueService
)
.
to
receive
(
:new
).
with
(
alert
,
User
.
alert_bot
)
expect
{
subject
}.
to
change
{
Issue
.
count
}.
by
(
1
)
end
it
'updates AlertManagement::Alert#issue_id'
do
subject
expect
(
alert
.
reload
.
issue_id
).
to
eq
(
created_issue
.
id
)
end
it
'does not write a warning to log'
do
subject
expect
(
Gitlab
::
AppLogger
).
not_to
have_received
(
:warn
)
end
end
context
'with valid alert'
do
it_behaves_like
'creates issue successfully'
context
'when alert cannot be updated'
do
let_it_be
(
:alert
)
{
create
(
:alert_management_alert
,
:with_validation_errors
,
project:
project
,
payload:
payload
)
}
it
'updates AlertManagement::Alert#issue_id'
do
expect
{
subject
}.
not_to
change
{
alert
.
reload
.
issue_id
}
end
it
'logs a warning'
do
subject
expect
(
Gitlab
::
AppLogger
).
to
have_received
(
:warn
).
with
(
message:
'Cannot process an Incident'
,
issue_id:
created_issue
.
id
,
alert_id:
alert
.
id
,
errors:
'Hosts hosts array is over 255 chars'
)
end
end
context
'prometheus alert'
do
let_it_be
(
:alert
)
{
create
(
:alert_management_alert
,
:prometheus
,
project:
project
,
started_at:
started_at
)
}
it_behaves_like
'creates issue successfully'
end
end
context
'with invalid alert'
do
let
(
:invalid_alert_id
)
{
non_existing_record_id
}
subject
{
described_class
.
new
.
perform
(
nil
,
nil
,
invalid_alert_id
)
}
it
'does not create issues'
do
expect
(
AlertManagement
::
CreateAlertIssueService
).
not_to
receive
(
:new
)
expect
{
subject
}.
not_to
change
{
Issue
.
count
}
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