diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-20 21:38:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-20 21:38:24 +0300 |
commit | 983a0bba5d2a042c4a3bbb22432ec192c7501d82 (patch) | |
tree | b153cd387c14ba23bd5a07514c7c01fddf6a78a0 /app/workers | |
parent | a2bddee2cdb38673df0e004d5b32d9f77797de64 (diff) |
Add latest changes from gitlab-org/gitlab@12-10-stable-ee
Diffstat (limited to 'app/workers')
-rw-r--r-- | app/workers/all_queues.yml | 9 | ||||
-rw-r--r-- | app/workers/concerns/cronjob_queue.rb | 10 | ||||
-rw-r--r-- | app/workers/create_commit_signature_worker.rb | 13 | ||||
-rw-r--r-- | app/workers/expire_pipeline_cache_worker.rb | 4 | ||||
-rw-r--r-- | app/workers/export_csv_worker.rb | 21 | ||||
-rw-r--r-- | app/workers/gitlab/jira_import/stage/finish_import_worker.rb | 2 | ||||
-rw-r--r-- | app/workers/project_daily_statistics_worker.rb | 1 |
7 files changed, 53 insertions, 7 deletions
diff --git a/app/workers/all_queues.yml b/app/workers/all_queues.yml index 38f518458d6..57d41bfaec2 100644 --- a/app/workers/all_queues.yml +++ b/app/workers/all_queues.yml @@ -709,7 +709,7 @@ :urgency: :high :resource_boundary: :cpu :weight: 3 - :idempotent: + :idempotent: true - :name: pipeline_creation:create_pipeline :feature_category: :continuous_integration :has_external_dependencies: @@ -1046,6 +1046,13 @@ :resource_boundary: :unknown :weight: 1 :idempotent: +- :name: export_csv + :feature_category: :issue_tracking + :has_external_dependencies: + :urgency: :low + :resource_boundary: :cpu + :weight: 1 + :idempotent: - :name: file_hook :feature_category: :integrations :has_external_dependencies: diff --git a/app/workers/concerns/cronjob_queue.rb b/app/workers/concerns/cronjob_queue.rb index 25ee4539cab..955387b5ad4 100644 --- a/app/workers/concerns/cronjob_queue.rb +++ b/app/workers/concerns/cronjob_queue.rb @@ -10,4 +10,14 @@ module CronjobQueue sidekiq_options retry: false worker_context project: nil, namespace: nil, user: nil end + + class_methods do + # Cronjobs never get scheduled with arguments, so this is safe to + # override + def context_for_arguments(_args) + return if Gitlab::ApplicationContext.current_context_include?('meta.caller_id') + + Gitlab::ApplicationContext.new(caller_id: "Cronjob") + end + end end diff --git a/app/workers/create_commit_signature_worker.rb b/app/workers/create_commit_signature_worker.rb index 3da21c56eff..9cbc75f8944 100644 --- a/app/workers/create_commit_signature_worker.rb +++ b/app/workers/create_commit_signature_worker.rb @@ -21,14 +21,19 @@ class CreateCommitSignatureWorker # rubocop:disable Scalability/IdempotentWorker return if commits.empty? - # This calculates and caches the signature in the database - commits.each do |commit| + # Instantiate commits first to lazily load the signatures + commits.map! do |commit| case commit.signature_type when :PGP - Gitlab::Gpg::Commit.new(commit).signature + Gitlab::Gpg::Commit.new(commit) when :X509 - Gitlab::X509::Commit.new(commit).signature + Gitlab::X509::Commit.new(commit) end + end + + # This calculates and caches the signature in the database + commits.each do |commit| + commit&.signature rescue => e Rails.logger.error("Failed to create signature for commit #{commit.id}. Error: #{e.message}") # rubocop:disable Gitlab/RailsLogger end diff --git a/app/workers/expire_pipeline_cache_worker.rb b/app/workers/expire_pipeline_cache_worker.rb index 1d2708cdb44..0710ef9298b 100644 --- a/app/workers/expire_pipeline_cache_worker.rb +++ b/app/workers/expire_pipeline_cache_worker.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ExpirePipelineCacheWorker # rubocop:disable Scalability/IdempotentWorker +class ExpirePipelineCacheWorker include ApplicationWorker include PipelineQueue @@ -8,6 +8,8 @@ class ExpirePipelineCacheWorker # rubocop:disable Scalability/IdempotentWorker urgency :high worker_resource_boundary :cpu + idempotent! + # rubocop: disable CodeReuse/ActiveRecord def perform(pipeline_id) pipeline = Ci::Pipeline.find_by(id: pipeline_id) diff --git a/app/workers/export_csv_worker.rb b/app/workers/export_csv_worker.rb new file mode 100644 index 00000000000..9e2b3ad9bb4 --- /dev/null +++ b/app/workers/export_csv_worker.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class ExportCsvWorker # rubocop:disable Scalability/IdempotentWorker + include ApplicationWorker + + feature_category :issue_tracking + worker_resource_boundary :cpu + + def perform(current_user_id, project_id, params) + @current_user = User.find(current_user_id) + @project = Project.find(project_id) + + params.symbolize_keys! + params[:project_id] = project_id + params.delete(:sort) + + issues = IssuesFinder.new(@current_user, params).execute + + Issues::ExportCsvService.new(issues, @project).email(@current_user) + end +end diff --git a/app/workers/gitlab/jira_import/stage/finish_import_worker.rb b/app/workers/gitlab/jira_import/stage/finish_import_worker.rb index 1d57b77ac7e..3e2cfe56cea 100644 --- a/app/workers/gitlab/jira_import/stage/finish_import_worker.rb +++ b/app/workers/gitlab/jira_import/stage/finish_import_worker.rb @@ -10,7 +10,7 @@ module Gitlab def import(project) JiraImport.cache_cleanup(project.id) - project.latest_jira_import&.finish! + project.latest_jira_import.finish! end end end diff --git a/app/workers/project_daily_statistics_worker.rb b/app/workers/project_daily_statistics_worker.rb index c60bee0ffdc..2166655115d 100644 --- a/app/workers/project_daily_statistics_worker.rb +++ b/app/workers/project_daily_statistics_worker.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +# Deprecated: https://gitlab.com/gitlab-org/gitlab/-/issues/214585 class ProjectDailyStatisticsWorker # rubocop:disable Scalability/IdempotentWorker include ApplicationWorker |