diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 17:34:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 17:34:42 +0300 |
commit | 9f46488805e86b1bc341ea1620b866016c2ce5ed (patch) | |
tree | f9748c7e287041e37d6da49e0a29c9511dc34768 /app/workers/incident_management | |
parent | dfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff) |
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'app/workers/incident_management')
-rw-r--r-- | app/workers/incident_management/process_alert_worker.rb | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/app/workers/incident_management/process_alert_worker.rb b/app/workers/incident_management/process_alert_worker.rb index 8d4294cc231..2ce9fe359b5 100644 --- a/app/workers/incident_management/process_alert_worker.rb +++ b/app/workers/incident_management/process_alert_worker.rb @@ -7,11 +7,14 @@ module IncidentManagement queue_namespace :incident_management feature_category :incident_management - def perform(project_id, alert) + def perform(project_id, alert_payload, am_alert_id = nil) project = find_project(project_id) return unless project - create_issue(project, alert) + new_issue = create_issue(project, alert_payload) + return unless am_alert_id && new_issue.persisted? + + link_issue_with_alert(am_alert_id, new_issue.id) end private @@ -20,10 +23,24 @@ module IncidentManagement Project.find_by_id(project_id) end - def create_issue(project, alert) + def create_issue(project, alert_payload) IncidentManagement::CreateIssueService - .new(project, alert) + .new(project, alert_payload) .execute end + + def link_issue_with_alert(alert_id, issue_id) + alert = AlertManagement::Alert.find_by_id(alert_id) + return unless alert + + return if alert.update(issue_id: issue_id) + + Gitlab::AppLogger.warn( + message: 'Cannot link an Issue with Alert', + issue_id: issue_id, + alert_id: alert_id, + alert_errors: alert.errors.messages + ) + end end end |