summaryrefslogtreecommitdiff
path: root/app/workers
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-09-19 01:45:44 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-09-19 01:45:44 +0000
commit85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch)
tree9160f299afd8c80c038f08e1545be119f5e3f1e1 /app/workers
parent15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff)
downloadgitlab-ce-85dc423f7090da0a52c73eb66faf22ddb20efff9.tar.gz
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/all_queues.yml102
-rw-r--r--app/workers/analytics/instance_statistics/count_job_trigger_worker.rb36
-rw-r--r--app/workers/analytics/instance_statistics/counter_job_worker.rb28
-rw-r--r--app/workers/ci/build_trace_chunk_flush_worker.rb10
-rw-r--r--app/workers/ci/create_cross_project_pipeline_worker.rb2
-rw-r--r--app/workers/ci/pipelines/create_artifact_worker.rb18
-rw-r--r--app/workers/ci/ref_delete_unlock_artifacts_worker.rb2
-rw-r--r--app/workers/ci_platform_metrics_update_cron_worker.rb16
-rw-r--r--app/workers/concerns/new_issuable.rb2
-rw-r--r--app/workers/delete_diff_files_worker.rb4
-rw-r--r--app/workers/delete_stored_files_worker.rb4
-rw-r--r--app/workers/git_garbage_collect_worker.rb12
-rw-r--r--app/workers/issue_placement_worker.rb49
-rw-r--r--app/workers/issue_rebalancing_worker.rb20
-rw-r--r--app/workers/jira_connect/sync_branch_worker.rb22
-rw-r--r--app/workers/jira_connect/sync_merge_request_worker.rb18
-rw-r--r--app/workers/merge_request_cleanup_refs_worker.rb23
-rw-r--r--app/workers/new_issue_worker.rb4
-rw-r--r--app/workers/new_note_worker.rb8
-rw-r--r--app/workers/object_storage/migrate_uploads_worker.rb8
-rw-r--r--app/workers/pages_remove_worker.rb17
-rw-r--r--app/workers/pages_transfer_worker.rb20
-rw-r--r--app/workers/pages_update_configuration_worker.rb10
-rw-r--r--app/workers/partition_creation_worker.rb2
-rw-r--r--app/workers/personal_access_tokens/expired_notification_worker.rb2
-rw-r--r--app/workers/pipeline_update_ci_ref_status_worker.rb18
-rw-r--r--app/workers/post_receive.rb23
-rw-r--r--app/workers/propagate_integration_worker.rb8
-rw-r--r--app/workers/propagate_service_template_worker.rb2
-rw-r--r--app/workers/repository_fork_worker.rb4
-rw-r--r--app/workers/run_pipeline_schedule_worker.rb4
-rw-r--r--app/workers/stuck_ci_jobs_worker.rb4
-rw-r--r--app/workers/stuck_merge_jobs_worker.rb2
-rw-r--r--app/workers/trending_projects_worker.rb2
-rw-r--r--app/workers/update_merge_requests_worker.rb2
-rw-r--r--app/workers/upload_checksum_worker.rb2
36 files changed, 413 insertions, 97 deletions
diff --git a/app/workers/all_queues.yml b/app/workers/all_queues.yml
index 2c871c55f0a..451decce9fb 100644
--- a/app/workers/all_queues.yml
+++ b/app/workers/all_queues.yml
@@ -115,6 +115,14 @@
:weight: 1
:idempotent:
:tags: []
+- :name: cronjob:analytics_instance_statistics_count_job_trigger
+ :feature_category: :instance_statistics
+ :has_external_dependencies:
+ :urgency: :low
+ :resource_boundary: :unknown
+ :weight: 1
+ :idempotent: true
+ :tags: []
- :name: cronjob:authorized_project_update_periodic_recalculate
:feature_category: :source_code_management
:has_external_dependencies:
@@ -131,6 +139,14 @@
:weight: 1
:idempotent:
:tags: []
+- :name: cronjob:ci_platform_metrics_update_cron
+ :feature_category: :continuous_integration
+ :has_external_dependencies:
+ :urgency: :low
+ :resource_boundary: :cpu
+ :weight: 1
+ :idempotent:
+ :tags: []
- :name: cronjob:container_expiration_policy
:feature_category: :container_registry
:has_external_dependencies:
@@ -723,6 +739,22 @@
:weight: 2
:idempotent:
:tags: []
+- :name: jira_connect:jira_connect_sync_branch
+ :feature_category: :integrations
+ :has_external_dependencies:
+ :urgency: :low
+ :resource_boundary: :unknown
+ :weight: 1
+ :idempotent:
+ :tags: []
+- :name: jira_connect:jira_connect_sync_merge_request
+ :feature_category: :integrations
+ :has_external_dependencies:
+ :urgency: :low
+ :resource_boundary: :unknown
+ :weight: 1
+ :idempotent:
+ :tags: []
- :name: jira_importer:jira_import_advance_stage
:feature_category: :importers
:has_external_dependencies:
@@ -881,7 +913,7 @@
:urgency: :low
:resource_boundary: :unknown
:weight: 1
- :idempotent:
+ :idempotent: true
:tags: []
- :name: pipeline_background:ci_daily_build_group_report_results
:feature_category: :continuous_integration
@@ -899,6 +931,14 @@
:weight: 1
:idempotent: true
:tags: []
+- :name: pipeline_background:ci_pipelines_create_artifact
+ :feature_category: :continuous_integration
+ :has_external_dependencies:
+ :urgency: :low
+ :resource_boundary: :unknown
+ :weight: 1
+ :idempotent: true
+ :tags: []
- :name: pipeline_background:ci_ref_delete_unlock_artifacts
:feature_category: :continuous_integration
:has_external_dependencies:
@@ -987,14 +1027,6 @@
:weight: 3
:idempotent:
:tags: []
-- :name: pipeline_default:pipeline_update_ci_ref_status
- :feature_category: :continuous_integration
- :has_external_dependencies:
- :urgency: :high
- :resource_boundary: :cpu
- :weight: 3
- :idempotent:
- :tags: []
- :name: pipeline_hooks:build_hooks
:feature_category: :continuous_integration
:has_external_dependencies:
@@ -1180,6 +1212,14 @@
:weight: 1
:idempotent: true
:tags: []
+- :name: analytics_instance_statistics_counter_job
+ :feature_category: :instance_statistics
+ :has_external_dependencies:
+ :urgency: :low
+ :resource_boundary: :unknown
+ :weight: 1
+ :idempotent: true
+ :tags: []
- :name: authorized_keys
:feature_category: :source_code_management
:has_external_dependencies:
@@ -1350,7 +1390,7 @@
:tags: []
- :name: flush_counter_increments
:feature_category: :not_owned
- :has_external_dependencies:
+ :has_external_dependencies:
:urgency: :low
:resource_boundary: :unknown
:weight: 1
@@ -1428,6 +1468,22 @@
:weight: 1
:idempotent:
:tags: []
+- :name: issue_placement
+ :feature_category: :issue_tracking
+ :has_external_dependencies:
+ :urgency: :high
+ :resource_boundary: :cpu
+ :weight: 2
+ :idempotent: true
+ :tags: []
+- :name: issue_rebalancing
+ :feature_category: :issue_tracking
+ :has_external_dependencies:
+ :urgency: :low
+ :resource_boundary: :unknown
+ :weight: 1
+ :idempotent: true
+ :tags: []
- :name: mailers
:feature_category:
:has_external_dependencies:
@@ -1442,7 +1498,15 @@
:urgency: :high
:resource_boundary: :unknown
:weight: 5
- :idempotent:
+ :idempotent:
+ :tags: []
+- :name: merge_request_cleanup_refs
+ :feature_category: :source_code_management
+ :has_external_dependencies:
+ :urgency: :low
+ :resource_boundary: :unknown
+ :weight: 1
+ :idempotent: true
:tags: []
- :name: merge_request_mergeability_check
:feature_category: :source_code_management
@@ -1524,6 +1588,22 @@
:weight: 1
:idempotent:
:tags: []
+- :name: pages_remove
+ :feature_category: :pages
+ :has_external_dependencies:
+ :urgency: :low
+ :resource_boundary: :unknown
+ :weight: 1
+ :idempotent:
+ :tags: []
+- :name: pages_transfer
+ :feature_category: :pages
+ :has_external_dependencies:
+ :urgency: :low
+ :resource_boundary: :unknown
+ :weight: 1
+ :idempotent:
+ :tags: []
- :name: pages_update_configuration
:feature_category: :pages
:has_external_dependencies:
diff --git a/app/workers/analytics/instance_statistics/count_job_trigger_worker.rb b/app/workers/analytics/instance_statistics/count_job_trigger_worker.rb
new file mode 100644
index 00000000000..a9976c6e5cb
--- /dev/null
+++ b/app/workers/analytics/instance_statistics/count_job_trigger_worker.rb
@@ -0,0 +1,36 @@
+# frozen_string_literal: true
+
+module Analytics
+ module InstanceStatistics
+ class CountJobTriggerWorker
+ include ApplicationWorker
+ include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
+
+ DEFAULT_DELAY = 3.minutes.freeze
+
+ feature_category :instance_statistics
+ urgency :low
+
+ idempotent!
+
+ def perform
+ return if Feature.disabled?(:store_instance_statistics_measurements, default_enabled: true)
+
+ recorded_at = Time.zone.now
+ measurement_identifiers = Analytics::InstanceStatistics::Measurement.identifiers
+
+ worker_arguments = Gitlab::Analytics::InstanceStatistics::WorkersArgumentBuilder.new(
+ measurement_identifiers: measurement_identifiers.values,
+ recorded_at: recorded_at
+ ).execute
+
+ perform_in = DEFAULT_DELAY.minutes.from_now
+ worker_arguments.each do |args|
+ CounterJobWorker.perform_in(perform_in, *args)
+
+ perform_in += DEFAULT_DELAY
+ end
+ end
+ end
+ end
+end
diff --git a/app/workers/analytics/instance_statistics/counter_job_worker.rb b/app/workers/analytics/instance_statistics/counter_job_worker.rb
new file mode 100644
index 00000000000..062b5ccc207
--- /dev/null
+++ b/app/workers/analytics/instance_statistics/counter_job_worker.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+module Analytics
+ module InstanceStatistics
+ class CounterJobWorker
+ include ApplicationWorker
+
+ feature_category :instance_statistics
+ urgency :low
+
+ idempotent!
+
+ def perform(measurement_identifier, min_id, max_id, recorded_at)
+ query_scope = ::Analytics::InstanceStatistics::Measurement::IDENTIFIER_QUERY_MAPPING[measurement_identifier].call
+
+ count = if min_id.nil? || max_id.nil? # table is empty
+ 0
+ else
+ Gitlab::Database::BatchCount.batch_count(query_scope, start: min_id, finish: max_id)
+ end
+
+ return if count == Gitlab::Database::BatchCounter::FALLBACK
+
+ InstanceStatistics::Measurement.insert_all([{ recorded_at: recorded_at, count: count, identifier: measurement_identifier }])
+ end
+ end
+ end
+end
diff --git a/app/workers/ci/build_trace_chunk_flush_worker.rb b/app/workers/ci/build_trace_chunk_flush_worker.rb
index fe59ba896a4..2908c7c2d0b 100644
--- a/app/workers/ci/build_trace_chunk_flush_worker.rb
+++ b/app/workers/ci/build_trace_chunk_flush_worker.rb
@@ -1,14 +1,16 @@
# frozen_string_literal: true
module Ci
- class BuildTraceChunkFlushWorker # rubocop:disable Scalability/IdempotentWorker
+ class BuildTraceChunkFlushWorker
include ApplicationWorker
include PipelineBackgroundQueue
+ idempotent!
+
# rubocop: disable CodeReuse/ActiveRecord
- def perform(build_trace_chunk_id)
- ::Ci::BuildTraceChunk.find_by(id: build_trace_chunk_id).try do |build_trace_chunk|
- build_trace_chunk.persist_data!
+ def perform(chunk_id)
+ ::Ci::BuildTraceChunk.find_by(id: chunk_id).try do |chunk|
+ chunk.persist_data!
end
end
# rubocop: enable CodeReuse/ActiveRecord
diff --git a/app/workers/ci/create_cross_project_pipeline_worker.rb b/app/workers/ci/create_cross_project_pipeline_worker.rb
index 713d0092b32..679574d9f60 100644
--- a/app/workers/ci/create_cross_project_pipeline_worker.rb
+++ b/app/workers/ci/create_cross_project_pipeline_worker.rb
@@ -9,7 +9,7 @@ module Ci
def perform(bridge_id)
::Ci::Bridge.find_by_id(bridge_id).try do |bridge|
- ::Ci::CreateCrossProjectPipelineService
+ ::Ci::CreateDownstreamPipelineService
.new(bridge.project, bridge.user)
.execute(bridge)
end
diff --git a/app/workers/ci/pipelines/create_artifact_worker.rb b/app/workers/ci/pipelines/create_artifact_worker.rb
new file mode 100644
index 00000000000..220df975503
--- /dev/null
+++ b/app/workers/ci/pipelines/create_artifact_worker.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+module Ci
+ module Pipelines
+ class CreateArtifactWorker
+ include ApplicationWorker
+ include PipelineBackgroundQueue
+
+ idempotent!
+
+ def perform(pipeline_id)
+ Ci::Pipeline.find_by_id(pipeline_id).try do |pipeline|
+ Ci::Pipelines::CreateArtifactService.new.execute(pipeline)
+ end
+ end
+ end
+ end
+end
diff --git a/app/workers/ci/ref_delete_unlock_artifacts_worker.rb b/app/workers/ci/ref_delete_unlock_artifacts_worker.rb
index 3b4a6fcf630..aaa77efbb74 100644
--- a/app/workers/ci/ref_delete_unlock_artifacts_worker.rb
+++ b/app/workers/ci/ref_delete_unlock_artifacts_worker.rb
@@ -10,7 +10,7 @@ module Ci
def perform(project_id, user_id, ref_path)
::Project.find_by_id(project_id).try do |project|
::User.find_by_id(user_id).try do |user|
- ::Ci::Ref.find_by_ref_path(ref_path).try do |ci_ref|
+ project.ci_refs.find_by_ref_path(ref_path).try do |ci_ref|
::Ci::UnlockArtifactsService
.new(project, user)
.execute(ci_ref)
diff --git a/app/workers/ci_platform_metrics_update_cron_worker.rb b/app/workers/ci_platform_metrics_update_cron_worker.rb
new file mode 100644
index 00000000000..ec1fc26fad3
--- /dev/null
+++ b/app/workers/ci_platform_metrics_update_cron_worker.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class CiPlatformMetricsUpdateCronWorker # rubocop:disable Scalability/IdempotentWorker
+ include ApplicationWorker
+
+ # This worker does not perform work scoped to a context
+ include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
+
+ feature_category :continuous_integration
+ urgency :low
+ worker_resource_boundary :cpu
+
+ def perform
+ CiPlatformMetric.insert_auto_devops_platform_targets!
+ end
+end
diff --git a/app/workers/concerns/new_issuable.rb b/app/workers/concerns/new_issuable.rb
index 22ba7c97309..482a74f49f7 100644
--- a/app/workers/concerns/new_issuable.rb
+++ b/app/workers/concerns/new_issuable.rb
@@ -27,6 +27,6 @@ module NewIssuable
# rubocop: enable CodeReuse/ActiveRecord
def log_error(record_class, record_id)
- Rails.logger.error("#{self.class}: couldn't find #{record_class} with ID=#{record_id}, skipping job") # rubocop:disable Gitlab/RailsLogger
+ Gitlab::AppLogger.error("#{self.class}: couldn't find #{record_class} with ID=#{record_id}, skipping job")
end
end
diff --git a/app/workers/delete_diff_files_worker.rb b/app/workers/delete_diff_files_worker.rb
index a6759a9d7c4..a31cf650b83 100644
--- a/app/workers/delete_diff_files_worker.rb
+++ b/app/workers/delete_diff_files_worker.rb
@@ -12,11 +12,11 @@ class DeleteDiffFilesWorker # rubocop:disable Scalability/IdempotentWorker
return if merge_request_diff.without_files?
MergeRequestDiff.transaction do
- merge_request_diff.clean!
-
MergeRequestDiffFile
.where(merge_request_diff_id: merge_request_diff.id)
.delete_all
+
+ merge_request_diff.clean!
end
end
# rubocop: enable CodeReuse/ActiveRecord
diff --git a/app/workers/delete_stored_files_worker.rb b/app/workers/delete_stored_files_worker.rb
index 9cf5631b7d8..689ac3dd0ce 100644
--- a/app/workers/delete_stored_files_worker.rb
+++ b/app/workers/delete_stored_files_worker.rb
@@ -9,8 +9,8 @@ class DeleteStoredFilesWorker # rubocop:disable Scalability/IdempotentWorker
def perform(class_name, keys)
klass = begin
class_name.constantize
- rescue NameError
- nil
+ rescue NameError
+ nil
end
unless klass
diff --git a/app/workers/git_garbage_collect_worker.rb b/app/workers/git_garbage_collect_worker.rb
index 6e4feea1b26..b0307571448 100644
--- a/app/workers/git_garbage_collect_worker.rb
+++ b/app/workers/git_garbage_collect_worker.rb
@@ -37,10 +37,7 @@ class GitGarbageCollectWorker # rubocop:disable Scalability/IdempotentWorker
# Refresh the branch cache in case garbage collection caused a ref lookup to fail
flush_ref_caches(project) if task == :gc
- if task != :pack_refs
- project.repository.expire_statistics_caches
- Projects::UpdateStatisticsService.new(project, nil, statistics: [:repository_size, :lfs_objects_size]).execute
- end
+ update_repository_statistics(project) if task != :pack_refs
# In case pack files are deleted, release libgit2 cache and open file
# descriptors ASAP instead of waiting for Ruby garbage collection
@@ -106,6 +103,13 @@ class GitGarbageCollectWorker # rubocop:disable Scalability/IdempotentWorker
project.repository.has_visible_content?
end
+ def update_repository_statistics(project)
+ project.repository.expire_statistics_caches
+ return if Gitlab::Database.read_only? # GitGarbageCollectWorker may be run on a Geo secondary
+
+ Projects::UpdateStatisticsService.new(project, nil, statistics: [:repository_size, :lfs_objects_size]).execute
+ end
+
def bitmaps_enabled?
Gitlab::CurrentSettings.housekeeping_bitmaps_enabled
end
diff --git a/app/workers/issue_placement_worker.rb b/app/workers/issue_placement_worker.rb
new file mode 100644
index 00000000000..a8d59e9125c
--- /dev/null
+++ b/app/workers/issue_placement_worker.rb
@@ -0,0 +1,49 @@
+# frozen_string_literal: true
+
+class IssuePlacementWorker
+ include ApplicationWorker
+
+ idempotent!
+ feature_category :issue_tracking
+ urgency :high
+ worker_resource_boundary :cpu
+ weight 2
+
+ # Move at most the most recent 100 issues
+ QUERY_LIMIT = 100
+
+ # rubocop: disable CodeReuse/ActiveRecord
+ def perform(issue_id, project_id = nil)
+ issue = find_issue(issue_id, project_id)
+ return unless issue
+
+ # Move the oldest 100 unpositioned items to the end.
+ # This is to deal with out-of-order execution of the worker,
+ # while preserving creation order.
+ to_place = Issue
+ .relative_positioning_query_base(issue)
+ .where(relative_position: nil)
+ .order({ created_at: :asc }, { id: :asc })
+ .limit(QUERY_LIMIT + 1)
+ .to_a
+
+ leftover = to_place.pop if to_place.count > QUERY_LIMIT
+
+ Issue.move_nulls_to_end(to_place)
+ Issues::BaseService.new(nil).rebalance_if_needed(to_place.max_by(&:relative_position))
+ IssuePlacementWorker.perform_async(nil, leftover.project_id) if leftover.present?
+ rescue RelativePositioning::NoSpaceLeft => e
+ Gitlab::ErrorTracking.log_exception(e, issue_id: issue_id, project_id: project_id)
+ IssueRebalancingWorker.perform_async(nil, project_id.presence || issue.project_id)
+ end
+ # rubocop: enable CodeReuse/ActiveRecord
+
+ def find_issue(issue_id, project_id)
+ return Issue.id_in(issue_id).first if issue_id
+
+ project = Project.id_in(project_id).first
+ return unless project
+
+ project.issues.first
+ end
+end
diff --git a/app/workers/issue_rebalancing_worker.rb b/app/workers/issue_rebalancing_worker.rb
new file mode 100644
index 00000000000..032ba5534e6
--- /dev/null
+++ b/app/workers/issue_rebalancing_worker.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class IssueRebalancingWorker
+ include ApplicationWorker
+
+ idempotent!
+ urgency :low
+ feature_category :issue_tracking
+
+ def perform(ignore = nil, project_id = nil)
+ return if project_id.nil?
+
+ project = Project.find(project_id)
+ issue = project.issues.first # All issues are equivalent as far as we are concerned
+
+ IssueRebalancingService.new(issue).execute
+ rescue ActiveRecord::RecordNotFound, IssueRebalancingService::TooManyIssues => e
+ Gitlab::ErrorTracking.log_exception(e, project_id: project_id)
+ end
+end
diff --git a/app/workers/jira_connect/sync_branch_worker.rb b/app/workers/jira_connect/sync_branch_worker.rb
new file mode 100644
index 00000000000..8c3416478fd
--- /dev/null
+++ b/app/workers/jira_connect/sync_branch_worker.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+module JiraConnect
+ class SyncBranchWorker # rubocop:disable Scalability/IdempotentWorker
+ include ApplicationWorker
+
+ queue_namespace :jira_connect
+ feature_category :integrations
+ loggable_arguments 1, 2
+
+ def perform(project_id, branch_name, commit_shas)
+ project = Project.find_by_id(project_id)
+
+ return unless project
+
+ branches = [project.repository.find_branch(branch_name)] if branch_name.present?
+ commits = project.commits_by(oids: commit_shas) if commit_shas.present?
+
+ JiraConnect::SyncService.new(project).execute(commits: commits, branches: branches)
+ end
+ end
+end
diff --git a/app/workers/jira_connect/sync_merge_request_worker.rb b/app/workers/jira_connect/sync_merge_request_worker.rb
new file mode 100644
index 00000000000..b78bb8dfe16
--- /dev/null
+++ b/app/workers/jira_connect/sync_merge_request_worker.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+module JiraConnect
+ class SyncMergeRequestWorker # rubocop:disable Scalability/IdempotentWorker
+ include ApplicationWorker
+
+ queue_namespace :jira_connect
+ feature_category :integrations
+
+ def perform(merge_request_id)
+ merge_request = MergeRequest.find_by_id(merge_request_id)
+
+ return unless merge_request && merge_request.project
+
+ JiraConnect::SyncService.new(merge_request.project).execute(merge_requests: [merge_request])
+ end
+ end
+end
diff --git a/app/workers/merge_request_cleanup_refs_worker.rb b/app/workers/merge_request_cleanup_refs_worker.rb
new file mode 100644
index 00000000000..37774658ba8
--- /dev/null
+++ b/app/workers/merge_request_cleanup_refs_worker.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+class MergeRequestCleanupRefsWorker
+ include ApplicationWorker
+
+ feature_category :source_code_management
+ idempotent!
+
+ def perform(merge_request_id)
+ merge_request = MergeRequest.find_by_id(merge_request_id)
+
+ unless merge_request
+ logger.error("Failed to find merge request with ID: #{merge_request_id}")
+ return
+ end
+
+ result = ::MergeRequests::CleanupRefsService.new(merge_request).execute
+
+ return if result[:status] == :success
+
+ logger.error("Failed cleanup refs of merge request (#{merge_request_id}): #{result[:message]}")
+ end
+end
diff --git a/app/workers/new_issue_worker.rb b/app/workers/new_issue_worker.rb
index e0e28767f8d..be9a168c3f6 100644
--- a/app/workers/new_issue_worker.rb
+++ b/app/workers/new_issue_worker.rb
@@ -12,8 +12,8 @@ class NewIssueWorker # rubocop:disable Scalability/IdempotentWorker
def perform(issue_id, user_id)
return unless objects_found?(issue_id, user_id)
- EventCreateService.new.open_issue(issuable, user)
- NotificationService.new.new_issue(issuable, user)
+ ::EventCreateService.new.open_issue(issuable, user)
+ ::NotificationService.new.new_issue(issuable, user)
issuable.create_cross_references!(user)
end
diff --git a/app/workers/new_note_worker.rb b/app/workers/new_note_worker.rb
index b31311b0e44..2bb2d0db55c 100644
--- a/app/workers/new_note_worker.rb
+++ b/app/workers/new_note_worker.rb
@@ -13,17 +13,11 @@ class NewNoteWorker # rubocop:disable Scalability/IdempotentWorker
# rubocop: disable CodeReuse/ActiveRecord
def perform(note_id, _params = {})
if note = Note.find_by(id: note_id)
- NotificationService.new.new_note(note) unless skip_notification?(note)
+ NotificationService.new.new_note(note) unless note.skip_notification?
Notes::PostProcessService.new(note).execute
else
Gitlab::AppLogger.error("NewNoteWorker: couldn't find note with ID=#{note_id}, skipping job")
end
end
# rubocop: enable CodeReuse/ActiveRecord
-
- private
-
- def skip_notification?(note)
- note.review.present?
- end
end
diff --git a/app/workers/object_storage/migrate_uploads_worker.rb b/app/workers/object_storage/migrate_uploads_worker.rb
index 33a0e0f5f88..f489e428e8d 100644
--- a/app/workers/object_storage/migrate_uploads_worker.rb
+++ b/app/workers/object_storage/migrate_uploads_worker.rb
@@ -41,16 +41,14 @@ module ObjectStorage
end
end
- # rubocop:disable Gitlab/RailsLogger
def report!(results)
success, failures = results.partition(&:success?)
- Rails.logger.info header(success, failures)
- Rails.logger.warn failures(failures)
+ Gitlab::AppLogger.info header(success, failures)
+ Gitlab::AppLogger.warn failures(failures)
raise MigrationFailures.new(failures.map(&:error)) if failures.any?
end
- # rubocop:enable Gitlab/RailsLogger
def header(success, failures)
_("Migrated %{success_count}/%{total_count} files.") % { success_count: success.count, total_count: success.count + failures.count }
@@ -104,7 +102,7 @@ module ObjectStorage
report!(results)
rescue SanityCheckError => e
# do not retry: the job is insane
- Rails.logger.warn "#{self.class}: Sanity check error (#{e.message})" # rubocop:disable Gitlab/RailsLogger
+ Gitlab::AppLogger.warn "#{self.class}: Sanity check error (#{e.message})"
end
# rubocop: enable CodeReuse/ActiveRecord
diff --git a/app/workers/pages_remove_worker.rb b/app/workers/pages_remove_worker.rb
new file mode 100644
index 00000000000..b83168fd7bd
--- /dev/null
+++ b/app/workers/pages_remove_worker.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class PagesRemoveWorker # rubocop:disable Scalability/IdempotentWorker
+ include ApplicationWorker
+
+ sidekiq_options retry: 3
+ feature_category :pages
+ loggable_arguments 0
+
+ def perform(project_id)
+ project = Project.find_by_id(project_id)
+ return unless project
+
+ project.remove_pages
+ project.pages_domains.delete_all
+ end
+end
diff --git a/app/workers/pages_transfer_worker.rb b/app/workers/pages_transfer_worker.rb
new file mode 100644
index 00000000000..f78564cc69d
--- /dev/null
+++ b/app/workers/pages_transfer_worker.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class PagesTransferWorker # rubocop:disable Scalability/IdempotentWorker
+ include ApplicationWorker
+
+ TransferFailedError = Class.new(StandardError)
+
+ feature_category :pages
+ loggable_arguments 0, 1
+
+ def perform(method, args)
+ return unless Gitlab::PagesTransfer::Async::METHODS.include?(method)
+
+ result = Gitlab::PagesTransfer.new.public_send(method, *args) # rubocop:disable GitlabSecurity/PublicSend
+
+ # If result isn't truthy, the move failed. Promote this to an
+ # exception so that it will be logged and retried appropriately
+ raise TransferFailedError unless result
+ end
+end
diff --git a/app/workers/pages_update_configuration_worker.rb b/app/workers/pages_update_configuration_worker.rb
index d0904db6b42..07238bae8c2 100644
--- a/app/workers/pages_update_configuration_worker.rb
+++ b/app/workers/pages_update_configuration_worker.rb
@@ -10,14 +10,6 @@ class PagesUpdateConfigurationWorker
project = Project.find_by_id(project_id)
return unless project
- result = Projects::UpdatePagesConfigurationService.new(project).execute
-
- # The ConfigurationService swallows all exceptions and wraps them in a status
- # we need to keep this while the feature flag still allows running this
- # service within a request.
- # But we might as well take advantage of sidekiq retries here.
- # We should let the service raise after we remove the feature flag
- # https://gitlab.com/gitlab-org/gitlab/-/issues/230695
- raise result[:exception] if result[:exception]
+ Projects::UpdatePagesConfigurationService.new(project).execute
end
end
diff --git a/app/workers/partition_creation_worker.rb b/app/workers/partition_creation_worker.rb
index b833e818b32..119ecd28003 100644
--- a/app/workers/partition_creation_worker.rb
+++ b/app/workers/partition_creation_worker.rb
@@ -9,5 +9,7 @@ class PartitionCreationWorker
def perform
Gitlab::Database::Partitioning::PartitionCreator.new.create_partitions
+ ensure
+ Gitlab::Database::Partitioning::PartitionMonitoring.new.report_metrics
end
end
diff --git a/app/workers/personal_access_tokens/expired_notification_worker.rb b/app/workers/personal_access_tokens/expired_notification_worker.rb
index c1b1f1a461d..2ff64ec51f3 100644
--- a/app/workers/personal_access_tokens/expired_notification_worker.rb
+++ b/app/workers/personal_access_tokens/expired_notification_worker.rb
@@ -8,8 +8,6 @@ module PersonalAccessTokens
feature_category :authentication_and_authorization
def perform(*args)
- return unless Feature.enabled?(:expired_pat_email_notification)
-
notification_service = NotificationService.new
User.with_personal_access_tokens_expired_today.find_each do |user|
diff --git a/app/workers/pipeline_update_ci_ref_status_worker.rb b/app/workers/pipeline_update_ci_ref_status_worker.rb
deleted file mode 100644
index 9b1a5d8e7cf..00000000000
--- a/app/workers/pipeline_update_ci_ref_status_worker.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# frozen_string_literal: true
-
-# NOTE: This class is unused and to be removed in 13.1~
-class PipelineUpdateCiRefStatusWorker # rubocop:disable Scalability/IdempotentWorker
- include ApplicationWorker
- include PipelineQueue
-
- urgency :high
- worker_resource_boundary :cpu
-
- def perform(pipeline_id)
- pipeline = Ci::Pipeline.find_by_id(pipeline_id)
-
- return unless pipeline
-
- Ci::UpdateCiRefStatusService.new(pipeline).call
- end
-end
diff --git a/app/workers/post_receive.rb b/app/workers/post_receive.rb
index 8f844bd0b47..4a93b1af166 100644
--- a/app/workers/post_receive.rb
+++ b/app/workers/post_receive.rb
@@ -12,8 +12,8 @@ class PostReceive # rubocop:disable Scalability/IdempotentWorker
def perform(gl_repository, identifier, changes, push_options = {})
container, project, repo_type = Gitlab::GlRepository.parse(gl_repository)
- if project.nil? && (!repo_type.snippet? || container.is_a?(ProjectSnippet))
- log("Triggered hook for non-existing project with gl_repository \"#{gl_repository}\"")
+ if container.nil? || (container.is_a?(ProjectSnippet) && project.nil?)
+ log("Triggered hook for non-existing gl_repository \"#{gl_repository}\"")
return false
end
@@ -24,7 +24,7 @@ class PostReceive # rubocop:disable Scalability/IdempotentWorker
post_received = Gitlab::GitPostReceive.new(container, identifier, changes, push_options)
if repo_type.wiki?
- process_wiki_changes(post_received, container)
+ process_wiki_changes(post_received, container.wiki)
elsif repo_type.project?
process_project_changes(post_received, container)
elsif repo_type.snippet?
@@ -59,18 +59,15 @@ class PostReceive # rubocop:disable Scalability/IdempotentWorker
after_project_changes_hooks(project, user, changes.refs, changes.repository_data)
end
- def process_wiki_changes(post_received, project)
- project.touch(:last_activity_at, :last_repository_updated_at)
- project.wiki.repository.expire_statistics_caches
- ProjectCacheWorker.perform_async(project.id, [], [:wiki_size])
-
+ def process_wiki_changes(post_received, wiki)
user = identify_user(post_received)
return false unless user
# We only need to expire certain caches once per push
- expire_caches(post_received, project.wiki.repository)
+ expire_caches(post_received, wiki.repository)
+ wiki.repository.expire_statistics_caches
- ::Git::WikiPushService.new(project, user, changes: post_received.changes).execute
+ ::Git::WikiPushService.new(wiki, user, changes: post_received.changes).execute
end
def process_snippet_changes(post_received, snippet)
@@ -78,10 +75,16 @@ class PostReceive # rubocop:disable Scalability/IdempotentWorker
return false unless user
+ replicate_snippet_changes(snippet)
+
expire_caches(post_received, snippet.repository)
Snippets::UpdateStatisticsService.new(snippet).execute
end
+ def replicate_snippet_changes(snippet)
+ # Used by Gitlab Geo
+ end
+
# Expire the repository status, branch, and tag cache once per push.
def expire_caches(post_received, repository)
repository.expire_status_cache if repository.empty?
diff --git a/app/workers/propagate_integration_worker.rb b/app/workers/propagate_integration_worker.rb
index 15c0e761a0a..68e38386372 100644
--- a/app/workers/propagate_integration_worker.rb
+++ b/app/workers/propagate_integration_worker.rb
@@ -7,10 +7,8 @@ class PropagateIntegrationWorker
idempotent!
loggable_arguments 1
- def perform(integration_id, overwrite)
- Admin::PropagateIntegrationService.propagate(
- integration: Service.find(integration_id),
- overwrite: overwrite
- )
+ # Keep overwrite parameter for backwards compatibility.
+ def perform(integration_id, overwrite = nil)
+ Admin::PropagateIntegrationService.propagate(Service.find(integration_id))
end
end
diff --git a/app/workers/propagate_service_template_worker.rb b/app/workers/propagate_service_template_worker.rb
index 37d5ccb656d..b02525b5106 100644
--- a/app/workers/propagate_service_template_worker.rb
+++ b/app/workers/propagate_service_template_worker.rb
@@ -12,7 +12,7 @@ class PropagateServiceTemplateWorker # rubocop:disable Scalability/IdempotentWor
def perform(template_id)
return unless try_obtain_lease_for(template_id)
- Projects::PropagateServiceTemplate.propagate(Service.find_by(id: template_id))
+ Admin::PropagateServiceTemplate.propagate(Service.find_by(id: template_id))
end
# rubocop: enable CodeReuse/ActiveRecord
diff --git a/app/workers/repository_fork_worker.rb b/app/workers/repository_fork_worker.rb
index 395fce0696c..fc7999e7837 100644
--- a/app/workers/repository_fork_worker.rb
+++ b/app/workers/repository_fork_worker.rb
@@ -34,7 +34,7 @@ class RepositoryForkWorker # rubocop:disable Scalability/IdempotentWorker
def start_fork(project)
return true if start(project.import_state)
- Rails.logger.info("Project #{project.full_path} was in inconsistent state (#{project.import_status}) while forking.") # rubocop:disable Gitlab/RailsLogger
+ Gitlab::AppLogger.info("Project #{project.full_path} was in inconsistent state (#{project.import_status}) while forking.")
false
end
@@ -52,7 +52,7 @@ class RepositoryForkWorker # rubocop:disable Scalability/IdempotentWorker
def link_lfs_objects(source_project, target_project)
Projects::LfsPointers::LfsLinkService
.new(target_project)
- .execute(source_project.all_lfs_objects_oids)
+ .execute(source_project.lfs_objects_oids)
rescue Projects::LfsPointers::LfsLinkService::TooManyOidsError
raise_fork_failure(
source_project,
diff --git a/app/workers/run_pipeline_schedule_worker.rb b/app/workers/run_pipeline_schedule_worker.rb
index 7d76cbed77f..605dd624260 100644
--- a/app/workers/run_pipeline_schedule_worker.rb
+++ b/app/workers/run_pipeline_schedule_worker.rb
@@ -31,11 +31,10 @@ class RunPipelineScheduleWorker # rubocop:disable Scalability/IdempotentWorker
private
- # rubocop:disable Gitlab/RailsLogger
def error(schedule, error)
failed_creation_counter.increment
- Rails.logger.error "Failed to create a scheduled pipeline. " \
+ Gitlab::AppLogger.error "Failed to create a scheduled pipeline. " \
"schedule_id: #{schedule.id} message: #{error.message}"
Gitlab::ErrorTracking
@@ -43,7 +42,6 @@ class RunPipelineScheduleWorker # rubocop:disable Scalability/IdempotentWorker
issue_url: 'https://gitlab.com/gitlab-org/gitlab-foss/issues/41231',
schedule_id: schedule.id)
end
- # rubocop:enable Gitlab/RailsLogger
def failed_creation_counter
@failed_creation_counter ||=
diff --git a/app/workers/stuck_ci_jobs_worker.rb b/app/workers/stuck_ci_jobs_worker.rb
index b3b1ed66efc..f8209ae5e63 100644
--- a/app/workers/stuck_ci_jobs_worker.rb
+++ b/app/workers/stuck_ci_jobs_worker.rb
@@ -17,7 +17,7 @@ class StuckCiJobsWorker # rubocop:disable Scalability/IdempotentWorker
def perform
return unless try_obtain_lease
- Rails.logger.info "#{self.class}: Cleaning stuck builds" # rubocop:disable Gitlab/RailsLogger
+ Gitlab::AppLogger.info "#{self.class}: Cleaning stuck builds" # rubocop:disable Gitlab/RailsLogger
drop :running, BUILD_RUNNING_OUTDATED_TIMEOUT, 'ci_builds.updated_at < ?', :stuck_or_timeout_failure
drop :pending, BUILD_PENDING_OUTDATED_TIMEOUT, 'ci_builds.updated_at < ?', :stuck_or_timeout_failure
@@ -69,7 +69,7 @@ class StuckCiJobsWorker # rubocop:disable Scalability/IdempotentWorker
# rubocop: enable CodeReuse/ActiveRecord
def drop_build(type, build, status, timeout, reason)
- Rails.logger.info "#{self.class}: Dropping #{type} build #{build.id} for runner #{build.runner_id} (status: #{status}, timeout: #{timeout}, reason: #{reason})" # rubocop:disable Gitlab/RailsLogger
+ Gitlab::AppLogger.info "#{self.class}: Dropping #{type} build #{build.id} for runner #{build.runner_id} (status: #{status}, timeout: #{timeout}, reason: #{reason})"
Gitlab::OptimisticLocking.retry_lock(build, 3) do |b|
b.drop(reason)
end
diff --git a/app/workers/stuck_merge_jobs_worker.rb b/app/workers/stuck_merge_jobs_worker.rb
index e0209b8237a..0f9b4ddb980 100644
--- a/app/workers/stuck_merge_jobs_worker.rb
+++ b/app/workers/stuck_merge_jobs_worker.rb
@@ -7,7 +7,7 @@ class StuckMergeJobsWorker # rubocop:disable Scalability/IdempotentWorker
feature_category :source_code_management
def self.logger
- Rails.logger # rubocop:disable Gitlab/RailsLogger
+ Gitlab::AppLogger
end
# rubocop: disable CodeReuse/ActiveRecord
diff --git a/app/workers/trending_projects_worker.rb b/app/workers/trending_projects_worker.rb
index ee7724e0fa8..eb1a7f4fef9 100644
--- a/app/workers/trending_projects_worker.rb
+++ b/app/workers/trending_projects_worker.rb
@@ -11,7 +11,7 @@ class TrendingProjectsWorker # rubocop:disable Scalability/IdempotentWorker
feature_category :source_code_management
def perform
- Rails.logger.info('Refreshing trending projects') # rubocop:disable Gitlab/RailsLogger
+ Gitlab::AppLogger.info('Refreshing trending projects')
TrendingProject.refresh!
end
diff --git a/app/workers/update_merge_requests_worker.rb b/app/workers/update_merge_requests_worker.rb
index 98534b258a7..402c1777662 100644
--- a/app/workers/update_merge_requests_worker.rb
+++ b/app/workers/update_merge_requests_worker.rb
@@ -9,8 +9,6 @@ class UpdateMergeRequestsWorker # rubocop:disable Scalability/IdempotentWorker
weight 3
loggable_arguments 2, 3, 4
- LOG_TIME_THRESHOLD = 90 # seconds
-
# rubocop: disable CodeReuse/ActiveRecord
def perform(project_id, user_id, oldrev, newrev, ref)
project = Project.find_by(id: project_id)
diff --git a/app/workers/upload_checksum_worker.rb b/app/workers/upload_checksum_worker.rb
index dc2511f718c..ce43b56bbd8 100644
--- a/app/workers/upload_checksum_worker.rb
+++ b/app/workers/upload_checksum_worker.rb
@@ -10,6 +10,6 @@ class UploadChecksumWorker # rubocop:disable Scalability/IdempotentWorker
upload.calculate_checksum!
upload.save!
rescue ActiveRecord::RecordNotFound
- Rails.logger.error("UploadChecksumWorker: couldn't find upload #{upload_id}, skipping") # rubocop:disable Gitlab/RailsLogger
+ Gitlab::AppLogger.error("UploadChecksumWorker: couldn't find upload #{upload_id}, skipping")
end
end