summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-08-10 23:02:09 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-08-10 23:02:09 +0000
commit8c21e23045073c07c43f4f4d9012ced728702e98 (patch)
treea14b5f617927e4f3419e599967eab727f4755491 /app
parent0a3f1f55493660acfabd198d2e1649a881d8852b (diff)
downloadgitlab-ce-8c21e23045073c07c43f4f4d9012ced728702e98.tar.gz
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'app')
-rw-r--r--app/services/alert_management/process_prometheus_alert_service.rb22
-rw-r--r--app/workers/incident_management/process_alert_worker.rb6
2 files changed, 22 insertions, 6 deletions
diff --git a/app/services/alert_management/process_prometheus_alert_service.rb b/app/services/alert_management/process_prometheus_alert_service.rb
index 573d3914c05..c233ea4e2e5 100644
--- a/app/services/alert_management/process_prometheus_alert_service.rb
+++ b/app/services/alert_management/process_prometheus_alert_service.rb
@@ -34,6 +34,8 @@ module AlertManagement
else
create_alert_management_alert
end
+
+ process_incident_alert
end
def reset_alert_management_alert_status
@@ -47,16 +49,17 @@ module AlertManagement
end
def create_alert_management_alert
- am_alert = AlertManagement::Alert.new(am_alert_params.merge(ended_at: nil))
- if am_alert.save
- am_alert.execute_services
+ new_alert = AlertManagement::Alert.new(am_alert_params.merge(ended_at: nil))
+ if new_alert.save
+ new_alert.execute_services
+ @am_alert = new_alert
return
end
logger.warn(
message: 'Unable to create AlertManagement::Alert',
project_id: project.id,
- alert_errors: am_alert.errors.messages
+ alert_errors: new_alert.errors.messages
)
end
@@ -89,12 +92,21 @@ module AlertManagement
SystemNoteService.auto_resolve_prometheus_alert(issue, project, User.alert_bot) if issue.reset.closed?
end
+ def process_incident_alert
+ return unless am_alert
+ return if am_alert.issue
+
+ IncidentManagement::ProcessAlertWorker.perform_async(nil, nil, am_alert.id)
+ end
+
def logger
@logger ||= Gitlab::AppLogger
end
def am_alert
- @am_alert ||= AlertManagement::Alert.not_resolved.for_fingerprint(project, gitlab_fingerprint).first
+ strong_memoize(:am_alert) do
+ AlertManagement::Alert.not_resolved.for_fingerprint(project, gitlab_fingerprint).first
+ end
end
def bad_request
diff --git a/app/workers/incident_management/process_alert_worker.rb b/app/workers/incident_management/process_alert_worker.rb
index bc23dbda693..5d5c10014f8 100644
--- a/app/workers/incident_management/process_alert_worker.rb
+++ b/app/workers/incident_management/process_alert_worker.rb
@@ -29,7 +29,11 @@ module IncidentManagement
end
def parsed_payload(alert)
- Gitlab::Alerting::NotificationPayloadParser.call(alert.payload.to_h, alert.project)
+ if alert.prometheus?
+ alert.payload
+ else
+ Gitlab::Alerting::NotificationPayloadParser.call(alert.payload.to_h, alert.project)
+ end
end
def create_issue_for(alert)