summaryrefslogtreecommitdiff
path: root/app/workers
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-11 15:08:44 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-11 15:08:44 +0000
commitbcc77054ee9aefd1e332e04a4189390fd5a3112e (patch)
treee6e1908c310e4733038794e932196cae0d66ba9a /app/workers
parent05b5c609cb8c260b10c2eb1b92b711dc82d32c3f (diff)
downloadgitlab-ce-bcc77054ee9aefd1e332e04a4189390fd5a3112e.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/all_queues.yml6
-rw-r--r--app/workers/concerns/worker_context.rb2
-rw-r--r--app/workers/container_expiration_policy_worker.rb10
-rw-r--r--app/workers/incident_management/process_alert_worker.rb29
4 files changed, 42 insertions, 5 deletions
diff --git a/app/workers/all_queues.yml b/app/workers/all_queues.yml
index e836dd92770..22dd7f5843f 100644
--- a/app/workers/all_queues.yml
+++ b/app/workers/all_queues.yml
@@ -429,6 +429,12 @@
:latency_sensitive:
:resource_boundary: :unknown
:weight: 1
+- :name: incident_management:incident_management_process_alert
+ :feature_category: :incident_management
+ :has_external_dependencies:
+ :latency_sensitive:
+ :resource_boundary: :unknown
+ :weight: 2
- :name: mail_scheduler:mail_scheduler_issue_due
:feature_category: :issue_tracking
:has_external_dependencies:
diff --git a/app/workers/concerns/worker_context.rb b/app/workers/concerns/worker_context.rb
index ca006eaad5d..f2ff3ecfb6b 100644
--- a/app/workers/concerns/worker_context.rb
+++ b/app/workers/concerns/worker_context.rb
@@ -60,6 +60,6 @@ module WorkerContext
end
def with_context(context, &block)
- Gitlab::ApplicationContext.new(context).use(&block)
+ Gitlab::ApplicationContext.new(context).use { yield(**context) }
end
end
diff --git a/app/workers/container_expiration_policy_worker.rb b/app/workers/container_expiration_policy_worker.rb
index a930dfa0186..e07a6546e2d 100644
--- a/app/workers/container_expiration_policy_worker.rb
+++ b/app/workers/container_expiration_policy_worker.rb
@@ -2,15 +2,17 @@
class ContainerExpirationPolicyWorker
include ApplicationWorker
- include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
+ include CronjobQueue
feature_category :container_registry
def perform
ContainerExpirationPolicy.runnable_schedules.preloaded.find_each do |container_expiration_policy|
- ContainerExpirationPolicyService.new(
- container_expiration_policy.project, container_expiration_policy.project.owner
- ).execute(container_expiration_policy)
+ with_context(project: container_expiration_policy.project,
+ user: container_expiration_policy.project.owner) do |project:, user:|
+ ContainerExpirationPolicyService.new(project, user)
+ .execute(container_expiration_policy)
+ end
end
end
end
diff --git a/app/workers/incident_management/process_alert_worker.rb b/app/workers/incident_management/process_alert_worker.rb
new file mode 100644
index 00000000000..f3d5bc5c66b
--- /dev/null
+++ b/app/workers/incident_management/process_alert_worker.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+module IncidentManagement
+ class ProcessAlertWorker
+ include ApplicationWorker
+
+ queue_namespace :incident_management
+ feature_category :incident_management
+
+ def perform(project_id, alert)
+ project = find_project(project_id)
+ return unless project
+
+ create_issue(project, alert)
+ end
+
+ private
+
+ def find_project(project_id)
+ Project.find_by_id(project_id)
+ end
+
+ def create_issue(project, alert)
+ IncidentManagement::CreateIssueService
+ .new(project, alert)
+ .execute
+ end
+ end
+end