diff options
Diffstat (limited to 'app/workers/incident_management')
5 files changed, 62 insertions, 0 deletions
diff --git a/app/workers/incident_management/add_severity_system_note_worker.rb b/app/workers/incident_management/add_severity_system_note_worker.rb index 9f132531562..62ed902e488 100644 --- a/app/workers/incident_management/add_severity_system_note_worker.rb +++ b/app/workers/incident_management/add_severity_system_note_worker.rb @@ -4,8 +4,11 @@ module IncidentManagement class AddSeveritySystemNoteWorker # rubocop:disable Scalability/IdempotentWorker include ApplicationWorker + sidekiq_options retry: 3 + queue_namespace :incident_management feature_category :incident_management + tags :exclude_from_kubernetes def perform(incident_id, user_id) return if incident_id.blank? || user_id.blank? diff --git a/app/workers/incident_management/pager_duty/process_incident_worker.rb b/app/workers/incident_management/pager_duty/process_incident_worker.rb index 3f378b012a1..413a297a024 100644 --- a/app/workers/incident_management/pager_duty/process_incident_worker.rb +++ b/app/workers/incident_management/pager_duty/process_incident_worker.rb @@ -5,6 +5,8 @@ module IncidentManagement class ProcessIncidentWorker # rubocop:disable Scalability/IdempotentWorker include ApplicationWorker + sidekiq_options retry: 3 + queue_namespace :incident_management feature_category :incident_management diff --git a/app/workers/incident_management/process_alert_worker.rb b/app/workers/incident_management/process_alert_worker.rb index 59464b81d1b..3b90e296ad4 100644 --- a/app/workers/incident_management/process_alert_worker.rb +++ b/app/workers/incident_management/process_alert_worker.rb @@ -4,12 +4,20 @@ 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 diff --git a/app/workers/incident_management/process_alert_worker_v2.rb b/app/workers/incident_management/process_alert_worker_v2.rb new file mode 100644 index 00000000000..04bf6970578 --- /dev/null +++ b/app/workers/incident_management/process_alert_worker_v2.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +module IncidentManagement + class ProcessAlertWorkerV2 # rubocop:disable Scalability/IdempotentWorker + include ApplicationWorker + + queue_namespace :incident_management + feature_category :incident_management + + idempotent! + + def perform(alert_id) + 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 diff --git a/app/workers/incident_management/process_prometheus_alert_worker.rb b/app/workers/incident_management/process_prometheus_alert_worker.rb index 4b778f6a621..7b5c6fd9001 100644 --- a/app/workers/incident_management/process_prometheus_alert_worker.rb +++ b/app/workers/incident_management/process_prometheus_alert_worker.rb @@ -4,6 +4,8 @@ module IncidentManagement class ProcessPrometheusAlertWorker # rubocop:disable Scalability/IdempotentWorker include ApplicationWorker + sidekiq_options retry: 3 + queue_namespace :incident_management feature_category :incident_management worker_resource_boundary :cpu |