diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /app/workers/incident_management | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'app/workers/incident_management')
-rw-r--r-- | app/workers/incident_management/process_alert_worker.rb | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/app/workers/incident_management/process_alert_worker.rb b/app/workers/incident_management/process_alert_worker.rb index 5d5c10014f8..59464b81d1b 100644 --- a/app/workers/incident_management/process_alert_worker.rb +++ b/app/workers/incident_management/process_alert_worker.rb @@ -16,10 +16,10 @@ module IncidentManagement alert = find_alert(alert_id) return unless alert - new_issue = create_issue_for(alert) - return unless new_issue&.persisted? + result = create_issue_for(alert) + return if result.success? - link_issue_with_alert(alert, new_issue.id) + log_warning(alert, result) end private @@ -28,29 +28,20 @@ module IncidentManagement AlertManagement::Alert.find_by_id(alert_id) end - def parsed_payload(alert) - if alert.prometheus? - alert.payload - else - Gitlab::Alerting::NotificationPayloadParser.call(alert.payload.to_h, alert.project) - end - end - def create_issue_for(alert) - IncidentManagement::CreateIssueService - .new(alert.project, parsed_payload(alert)) + AlertManagement::CreateAlertIssueService + .new(alert, User.alert_bot) .execute - .dig(:issue) end - def link_issue_with_alert(alert, issue_id) - return if alert.update(issue_id: issue_id) + def log_warning(alert, result) + issue_id = result.payload[:issue]&.id Gitlab::AppLogger.warn( - message: 'Cannot link an Issue with Alert', + message: 'Cannot process an Incident', issue_id: issue_id, alert_id: alert.id, - alert_errors: alert.errors.messages + errors: result.message ) end end |