Commit 88bee24b authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'an-sidekiq-job-feature-attribution' into 'master'

Attribute Sidekiq workers to feature categories

Closes gitlab-com/gl-infra/scalability#32

See merge request gitlab-org/gitlab!18462
parents fc9e1625 049a4d4c
# frozen_string_literal: true
module WorkerAttributes
extend ActiveSupport::Concern
class_methods do
def feature_category(value)
raise "Invalid category. Use `feature_category_not_owned!` to mark a worker as not owned" if value == :not_owned
worker_attributes[:feature_category] = value
end
# Special case: mark this work as not associated with a feature category
# this should be used for cross-cutting concerns, such as mailer workers.
def feature_category_not_owned!
worker_attributes[:feature_category] = :not_owned
end
def get_feature_category
get_worker_attribute(:feature_category)
end
def feature_category_not_owned?
get_worker_attribute(:feature_category) == :not_owned
end
protected
# Returns a worker attribute declared on this class or its parent class.
# This approach allows declared attributes to be inherited by
# child classes.
def get_worker_attribute(name)
worker_attributes[name] || superclass_worker_attributes(name)
end
private
def worker_attributes
@attributes ||= {}
end
def superclass_worker_attributes(name)
return unless superclass.include? WorkerAttributes
superclass.get_worker_attribute(name)
end
end
end
...@@ -4,6 +4,8 @@ class AdminEmailWorker ...@@ -4,6 +4,8 @@ class AdminEmailWorker
include ApplicationWorker include ApplicationWorker
include CronjobQueue include CronjobQueue
feature_category_not_owned!
def perform def perform
send_repository_check_mail if Gitlab::CurrentSettings.repository_checks_enabled send_repository_check_mail if Gitlab::CurrentSettings.repository_checks_enabled
end end
......
...@@ -4,6 +4,8 @@ class AuthorizedProjectsWorker ...@@ -4,6 +4,8 @@ class AuthorizedProjectsWorker
include ApplicationWorker include ApplicationWorker
prepend WaitableWorker prepend WaitableWorker
feature_category :authentication_and_authorization
# This is a workaround for a Ruby 2.3.7 bug. rspec-mocks cannot restore the # This is a workaround for a Ruby 2.3.7 bug. rspec-mocks cannot restore the
# visibility of prepended modules. See https://github.com/rspec/rspec-mocks/issues/1231 # visibility of prepended modules. See https://github.com/rspec/rspec-mocks/issues/1231
# for more details. # for more details.
......
...@@ -4,6 +4,7 @@ class AutoMergeProcessWorker ...@@ -4,6 +4,7 @@ class AutoMergeProcessWorker
include ApplicationWorker include ApplicationWorker
queue_namespace :auto_merge queue_namespace :auto_merge
feature_category :continuous_delivery
def perform(merge_request_id) def perform(merge_request_id)
MergeRequest.find_by_id(merge_request_id).try do |merge_request| MergeRequest.find_by_id(merge_request_id).try do |merge_request|
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
class BackgroundMigrationWorker class BackgroundMigrationWorker
include ApplicationWorker include ApplicationWorker
feature_category_not_owned!
# The minimum amount of time between processing two jobs of the same migration # The minimum amount of time between processing two jobs of the same migration
# class. # class.
# #
......
...@@ -5,6 +5,7 @@ class BuildHooksWorker ...@@ -5,6 +5,7 @@ class BuildHooksWorker
include PipelineQueue include PipelineQueue
queue_namespace :pipeline_hooks queue_namespace :pipeline_hooks
feature_category :continuous_integration
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def perform(build_id) def perform(build_id)
......
...@@ -5,6 +5,7 @@ class BuildQueueWorker ...@@ -5,6 +5,7 @@ class BuildQueueWorker
include PipelineQueue include PipelineQueue
queue_namespace :pipeline_processing queue_namespace :pipeline_processing
feature_category :continuous_integration
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def perform(build_id) def perform(build_id)
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
class ChatNotificationWorker class ChatNotificationWorker
include ApplicationWorker include ApplicationWorker
feature_category :chatops
RESCHEDULE_INTERVAL = 2.seconds RESCHEDULE_INTERVAL = 2.seconds
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
......
...@@ -5,6 +5,8 @@ module Ci ...@@ -5,6 +5,8 @@ module Ci
include ApplicationWorker include ApplicationWorker
include CronjobQueue include CronjobQueue
feature_category :continuous_integration
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def perform def perform
# Archive stale live traces which still resides in redis or database # Archive stale live traces which still resides in redis or database
......
...@@ -6,6 +6,7 @@ module Ci ...@@ -6,6 +6,7 @@ module Ci
include PipelineQueue include PipelineQueue
queue_namespace :pipeline_processing queue_namespace :pipeline_processing
feature_category :continuous_integration
def perform(build_id) def perform(build_id)
Ci::Build.find_by_id(build_id).try do |build| Ci::Build.find_by_id(build_id).try do |build|
......
...@@ -6,6 +6,7 @@ module Ci ...@@ -6,6 +6,7 @@ module Ci
include PipelineQueue include PipelineQueue
queue_namespace :pipeline_processing queue_namespace :pipeline_processing
feature_category :continuous_integration
def perform(build_id) def perform(build_id)
::Ci::Build.find_by_id(build_id).try do |build| ::Ci::Build.find_by_id(build_id).try do |build|
......
...@@ -4,6 +4,7 @@ class CleanupContainerRepositoryWorker ...@@ -4,6 +4,7 @@ class CleanupContainerRepositoryWorker
include ApplicationWorker include ApplicationWorker
queue_namespace :container_repository queue_namespace :container_repository
feature_category :container_registry
attr_reader :container_repository, :current_user attr_reader :container_repository, :current_user
......
...@@ -8,6 +8,7 @@ module ApplicationWorker ...@@ -8,6 +8,7 @@ module ApplicationWorker
extend ActiveSupport::Concern extend ActiveSupport::Concern
include Sidekiq::Worker # rubocop:disable Cop/IncludeSidekiqWorker include Sidekiq::Worker # rubocop:disable Cop/IncludeSidekiqWorker
include WorkerAttributes
included do included do
set_queue set_queue
......
...@@ -5,5 +5,6 @@ module AutoDevopsQueue ...@@ -5,5 +5,6 @@ module AutoDevopsQueue
included do included do
queue_namespace :auto_devops queue_namespace :auto_devops
feature_category :auto_devops
end end
end end
...@@ -5,5 +5,6 @@ module ChaosQueue ...@@ -5,5 +5,6 @@ module ChaosQueue
included do included do
queue_namespace :chaos queue_namespace :chaos
feature_category :chaos_engineering
end end
end end
...@@ -8,5 +8,6 @@ module ClusterQueue ...@@ -8,5 +8,6 @@ module ClusterQueue
included do included do
queue_namespace :gcp_cluster queue_namespace :gcp_cluster
feature_category :kubernetes_configuration
end end
end end
...@@ -12,6 +12,8 @@ module Gitlab ...@@ -12,6 +12,8 @@ module Gitlab
include GithubImport::Queue include GithubImport::Queue
include ReschedulingMethods include ReschedulingMethods
include NotifyUponDeath include NotifyUponDeath
feature_category :importers
end end
# project - An instance of `Project` to import the data into. # project - An instance of `Project` to import the data into.
......
...@@ -7,6 +7,7 @@ module Gitlab ...@@ -7,6 +7,7 @@ module Gitlab
included do included do
queue_namespace :github_importer queue_namespace :github_importer
feature_category :importers
# If a job produces an error it may block a stage from advancing # If a job produces an error it may block a stage from advancing
# forever. To prevent this from happening we prevent jobs from going to # forever. To prevent this from happening we prevent jobs from going to
......
...@@ -8,5 +8,6 @@ module ObjectPoolQueue ...@@ -8,5 +8,6 @@ module ObjectPoolQueue
included do included do
queue_namespace :object_pool queue_namespace :object_pool
feature_category :gitaly
end end
end end
...@@ -8,5 +8,6 @@ module PipelineBackgroundQueue ...@@ -8,5 +8,6 @@ module PipelineBackgroundQueue
included do included do
queue_namespace :pipeline_background queue_namespace :pipeline_background
feature_category :continuous_integration
end end
end end
...@@ -8,5 +8,6 @@ module PipelineQueue ...@@ -8,5 +8,6 @@ module PipelineQueue
included do included do
queue_namespace :pipeline_default queue_namespace :pipeline_default
feature_category :continuous_integration
end end
end end
...@@ -6,7 +6,7 @@ module RepositoryCheckQueue ...@@ -6,7 +6,7 @@ module RepositoryCheckQueue
included do included do
queue_namespace :repository_check queue_namespace :repository_check
sidekiq_options retry: false sidekiq_options retry: false
feature_category :source_code_management
end end
end end
...@@ -8,5 +8,6 @@ module TodosDestroyerQueue ...@@ -8,5 +8,6 @@ module TodosDestroyerQueue
included do included do
queue_namespace :todos_destroyer queue_namespace :todos_destroyer
feature_category :issue_tracking
end end
end end
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
class CreateEvidenceWorker class CreateEvidenceWorker
include ApplicationWorker include ApplicationWorker
feature_category :release_governance
def perform(release_id) def perform(release_id)
release = Release.find_by_id(release_id) release = Release.find_by_id(release_id)
return unless release return unless release
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
class CreateGpgSignatureWorker class CreateGpgSignatureWorker
include ApplicationWorker include ApplicationWorker
feature_category :source_code_management
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def perform(commit_shas, project_id) def perform(commit_shas, project_id)
# Older versions of Git::BranchPushService may push a single commit ID on # Older versions of Git::BranchPushService may push a single commit ID on
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
class CreateNoteDiffFileWorker class CreateNoteDiffFileWorker
include ApplicationWorker include ApplicationWorker
feature_category :source_code_management
def perform(diff_note_id) def perform(diff_note_id)
diff_note = DiffNote.find(diff_note_id) diff_note = DiffNote.find(diff_note_id)
......
...@@ -5,6 +5,7 @@ class CreatePipelineWorker ...@@ -5,6 +5,7 @@ class CreatePipelineWorker
include PipelineQueue include PipelineQueue
queue_namespace :pipeline_creation queue_namespace :pipeline_creation
feature_category :continuous_integration
def perform(project_id, user_id, ref, source, params = {}) def perform(project_id, user_id, ref, source, params = {})
project = Project.find(project_id) project = Project.find(project_id)
......
...@@ -5,6 +5,7 @@ class DeleteContainerRepositoryWorker ...@@ -5,6 +5,7 @@ class DeleteContainerRepositoryWorker
include ExclusiveLeaseGuard include ExclusiveLeaseGuard
queue_namespace :container_repository queue_namespace :container_repository
feature_category :container_registry
LEASE_TIMEOUT = 1.hour LEASE_TIMEOUT = 1.hour
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
class DeleteDiffFilesWorker class DeleteDiffFilesWorker
include ApplicationWorker include ApplicationWorker
feature_category :source_code_management
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def perform(merge_request_diff_id) def perform(merge_request_diff_id)
merge_request_diff = MergeRequestDiff.find(merge_request_diff_id) merge_request_diff = MergeRequestDiff.find(merge_request_diff_id)
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
class DeleteMergedBranchesWorker class DeleteMergedBranchesWorker
include ApplicationWorker include ApplicationWorker
feature_category :source_code_management
def perform(project_id, user_id) def perform(project_id, user_id)
begin begin
project = Project.find(project_id) project = Project.find(project_id)
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
class DeleteStoredFilesWorker class DeleteStoredFilesWorker
include ApplicationWorker include ApplicationWorker
feature_category_not_owned!
def perform(class_name, keys) def perform(class_name, keys)
klass = begin klass = begin
class_name.constantize class_name.constantize
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
class DeleteUserWorker class DeleteUserWorker
include ApplicationWorker include ApplicationWorker
feature_category :authentication_and_authorization
def perform(current_user_id, delete_user_id, options = {}) def perform(current_user_id, delete_user_id, options = {})
delete_user = User.find(delete_user_id) delete_user = User.find(delete_user_id)
current_user = User.find(current_user_id) current_user = User.find(current_user_id)
......
...@@ -5,6 +5,7 @@ module Deployments ...@@ -5,6 +5,7 @@ module Deployments
include ApplicationWorker include ApplicationWorker
queue_namespace :deployment queue_namespace :deployment
feature_category :continuous_delivery
def perform(deployment_id) def perform(deployment_id)
Deployment.find_by_id(deployment_id).try(:execute_hooks) Deployment.find_by_id(deployment_id).try(:execute_hooks)
......
...@@ -5,6 +5,7 @@ module Deployments ...@@ -5,6 +5,7 @@ module Deployments
include ApplicationWorker include ApplicationWorker
queue_namespace :deployment queue_namespace :deployment
feature_category :continuous_delivery
def perform(deployment_id) def perform(deployment_id)
Deployment.find_by_id(deployment_id).try do |deployment| Deployment.find_by_id(deployment_id).try do |deployment|
......
...@@ -6,6 +6,7 @@ class DetectRepositoryLanguagesWorker ...@@ -6,6 +6,7 @@ class DetectRepositoryLanguagesWorker
include ExclusiveLeaseGuard include ExclusiveLeaseGuard
sidekiq_options retry: 1 sidekiq_options retry: 1
feature_category :source_code_management
LEASE_TIMEOUT = 300 LEASE_TIMEOUT = 300
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
class EmailReceiverWorker class EmailReceiverWorker
include ApplicationWorker include ApplicationWorker
feature_category :issue_tracking
def perform(raw) def perform(raw)
return unless Gitlab::IncomingEmail.enabled? return unless Gitlab::IncomingEmail.enabled?
......
...@@ -5,6 +5,8 @@ class EmailsOnPushWorker ...@@ -5,6 +5,8 @@ class EmailsOnPushWorker
attr_reader :email, :skip_premailer attr_reader :email, :skip_premailer
feature_category :source_code_management
def perform(project_id, recipients, push_data, options = {}) def perform(project_id, recipients, push_data, options = {})
options.symbolize_keys! options.symbolize_keys!
options.reverse_merge!( options.reverse_merge!(
......
...@@ -4,6 +4,8 @@ class ExpireBuildArtifactsWorker ...@@ -4,6 +4,8 @@ class ExpireBuildArtifactsWorker
include ApplicationWorker include ApplicationWorker
include CronjobQueue include CronjobQueue
feature_category :continuous_integration
def perform def perform
if Feature.enabled?(:ci_new_expire_job_artifacts_service, default_enabled: true) if Feature.enabled?(:ci_new_expire_job_artifacts_service, default_enabled: true)
perform_efficient_artifacts_removal perform_efficient_artifacts_removal
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
class ExpireBuildInstanceArtifactsWorker class ExpireBuildInstanceArtifactsWorker
include ApplicationWorker include ApplicationWorker
feature_category :continuous_integration
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def perform(build_id) def perform(build_id)
build = Ci::Build build = Ci::Build
......
...@@ -4,6 +4,7 @@ class GitGarbageCollectWorker ...@@ -4,6 +4,7 @@ class GitGarbageCollectWorker
include ApplicationWorker include ApplicationWorker
sidekiq_options retry: false sidekiq_options retry: false
feature_category :gitaly
# Timeout set to 24h # Timeout set to 24h
LEASE_TIMEOUT = 86400 LEASE_TIMEOUT = 86400
......
...@@ -10,6 +10,7 @@ module Gitlab ...@@ -10,6 +10,7 @@ module Gitlab
include ApplicationWorker include ApplicationWorker
sidekiq_options dead: false sidekiq_options dead: false
feature_category :importers
INTERVAL = 30.seconds.to_i INTERVAL = 30.seconds.to_i
......
...@@ -4,6 +4,8 @@ class GitlabShellWorker ...@@ -4,6 +4,8 @@ class GitlabShellWorker
include ApplicationWorker include ApplicationWorker
include Gitlab::ShellAdapter include Gitlab::ShellAdapter
feature_category :source_code_management
def perform(action, *arg) def perform(action, *arg)
gitlab_shell.__send__(action, *arg) # rubocop:disable GitlabSecurity/PublicSend gitlab_shell.__send__(action, *arg) # rubocop:disable GitlabSecurity/PublicSend
end end
......
...@@ -6,6 +6,8 @@ class GitlabUsagePingWorker ...@@ -6,6 +6,8 @@ class GitlabUsagePingWorker
include ApplicationWorker include ApplicationWorker
include CronjobQueue include CronjobQueue
feature_category_not_owned!
# Retry for up to approximately three hours then give up. # Retry for up to approximately three hours then give up.
sidekiq_options retry: 10, dead: false sidekiq_options retry: 10, dead: false
......
...@@ -4,6 +4,8 @@ class GroupDestroyWorker ...@@ -4,6 +4,8 @@ class GroupDestroyWorker
include ApplicationWorker include ApplicationWorker
include ExceptionBacktrace include ExceptionBacktrace
feature_category :groups
def perform(group_id, user_id) def perform(group_id, user_id)
begin begin
group = Group.find(group_id) group = Group.find(group_id)
......
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
module HashedStorage module HashedStorage
class BaseWorker class BaseWorker
include ExclusiveLeaseGuard include ExclusiveLeaseGuard
include WorkerAttributes
feature_category :source_code_management
LEASE_TIMEOUT = 30.seconds.to_i LEASE_TIMEOUT = 30.seconds.to_i
LEASE_KEY_SEGMENT = 'project_migrate_hashed_storage_worker' LEASE_KEY_SEGMENT = 'project_migrate_hashed_storage_worker'
......
...@@ -5,6 +5,7 @@ module HashedStorage ...@@ -5,6 +5,7 @@ module HashedStorage
include ApplicationWorker include ApplicationWorker
queue_namespace :hashed_storage queue_namespace :hashed_storage
feature_category :source_code_management
# @param [Integer] start initial ID of the batch # @param [Integer] start initial ID of the batch
# @param [Integer] finish last ID of the batch # @param [Integer] finish last ID of the batch
......
...@@ -5,6 +5,7 @@ module HashedStorage ...@@ -5,6 +5,7 @@ module HashedStorage
include ApplicationWorker include ApplicationWorker
queue_namespace :hashed_storage queue_namespace :hashed_storage
feature_category :source_code_management
# @param [Integer] start initial ID of the batch # @param [Integer] start initial ID of the batch
# @param [Integer] finish last ID of the batch # @param [Integer] finish last ID of the batch
......
...@@ -4,6 +4,8 @@ class ImportExportProjectCleanupWorker ...@@ -4,6 +4,8 @@ class ImportExportProjectCleanupWorker
include ApplicationWorker include ApplicationWorker
include CronjobQueue include CronjobQueue
feature_category :importers
def perform def perform
ImportExportCleanUpService.new.execute ImportExportCleanUpService.new.execute
end end
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
class ImportIssuesCsvWorker class ImportIssuesCsvWorker
include ApplicationWorker include ApplicationWorker
feature_category :issue_tracking
sidekiq_retries_exhausted do |job| sidekiq_retries_exhausted do |job|
Upload.find(job['args'][2]).destroy Upload.find(job['args'][2]).destroy
end end
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
class InvalidGpgSignatureUpdateWorker class InvalidGpgSignatureUpdateWorker
include ApplicationWorker include ApplicationWorker
feature_category :source_code_management
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def perform(gpg_key_id) def perform(gpg_key_id)
gpg_key = GpgKey.find_by(id: gpg_key_id) gpg_key = GpgKey.find_by(id: gpg_key_id)
......
...@@ -6,6 +6,8 @@ require 'socket' ...@@ -6,6 +6,8 @@ require 'socket'
class IrkerWorker class IrkerWorker
include ApplicationWorker include ApplicationWorker
feature_category :integrations
def perform(project_id, chans, colors, push_data, settings) def perform(project_id, chans, colors, push_data, settings)
project = Project.find(project_id) project = Project.find(project_id)
......
...@@ -4,6 +4,8 @@ class IssueDueSchedulerWorker ...@@ -4,6 +4,8 @@ class IssueDueSchedulerWorker
include ApplicationWorker include ApplicationWorker
include CronjobQueue include CronjobQueue
feature_category :issue_tracking
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def perform def perform
project_ids = Issue.opened.due_tomorrow.group(:project_id).pluck(:project_id).map { |id| [id] } project_ids = Issue.opened.due_tomorrow.group(:project_id).pluck(:project_id).map { |id| [id] }
......
...@@ -5,6 +5,8 @@ module MailScheduler ...@@ -5,6 +5,8 @@ module MailScheduler
include ApplicationWorker include ApplicationWorker
include MailSchedulerQueue include MailSchedulerQueue
feature_category :issue_tracking
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def perform(project_id) def perform(project_id)
Issue.opened.due_tomorrow.in_projects(project_id).preload(:project).find_each do |issue| Issue.opened.due_tomorrow.in_projects(project_id).preload(:project).find_each do |issue|
......
...@@ -7,6 +7,8 @@ module MailScheduler ...@@ -7,6 +7,8 @@ module MailScheduler
include ApplicationWorker include ApplicationWorker
include MailSchedulerQueue include MailSchedulerQueue
feature_category :issue_tracking
def perform(meth, *args) def perform(meth, *args)
check_arguments!(args) check_arguments!(args)
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
class MergeWorker class MergeWorker
include ApplicationWorker include ApplicationWorker
feature_category :source_code_management
def perform(merge_request_id, current_user_id, params) def perform(merge_request_id, current_user_id, params)
params = params.with_indifferent_access params = params.with_indifferent_access
current_user = User.find(current_user_id) current_user = User.find(current_user_id)
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
class MigrateExternalDiffsWorker class MigrateExternalDiffsWorker
include ApplicationWorker include ApplicationWorker
feature_category :source_code_management
def perform(merge_request_diff_id) def perform(merge_request_diff_id)
diff = MergeRequestDiff.find_by_id(merge_request_diff_id) diff = MergeRequestDiff.find_by_id(merge_request_diff_id)
return unless diff return unless diff
......
...@@ -10,6 +10,8 @@ class NamespacelessProjectDestroyWorker ...@@ -10,6 +10,8 @@ class NamespacelessProjectDestroyWorker
include ApplicationWorker include ApplicationWorker
include ExceptionBacktrace include ExceptionBacktrace
feature_category :authentication_and_authorization
def perform(project_id) def perform(project_id)
begin begin
project = Project.unscoped.find(project_id) project = Project.unscoped.find(project_id)
......
...@@ -5,6 +5,8 @@ module Namespaces ...@@ -5,6 +5,8 @@ module Namespaces
include ApplicationWorker include ApplicationWorker
include CronjobQueue include CronjobQueue
feature_category :source_code_management
# Worker to prune pending rows on Namespace::AggregationSchedule # Worker to prune pending rows on Namespace::AggregationSchedule
# It's scheduled to run once a day at 1:05am. # It's scheduled to run once a day at 1:05am.
def perform def perform
......
...@@ -5,6 +5,7 @@ module Namespaces ...@@ -5,6 +5,7 @@ module Namespaces
include ApplicationWorker include ApplicationWorker
queue_namespace :update_namespace_statistics queue_namespace :update_namespace_statistics
feature_category :source_code_management
def perform(namespace_id) def perform(namespace_id)
namespace = Namespace.find(namespace_id) namespace = Namespace.find(namespace_id)
......
...@@ -5,6 +5,7 @@ module Namespaces ...@@ -5,6 +5,7 @@ module Namespaces
include ApplicationWorker include ApplicationWorker
queue_namespace :update_namespace_statistics queue_namespace :update_namespace_statistics
feature_category :source_code_management
def perform(namespace_id) def perform(namespace_id)
return unless aggregation_schedules_table_exists? return unless aggregation_schedules_table_exists?
......
...@@ -4,6 +4,8 @@ class NewIssueWorker ...@@ -4,6 +4,8 @@ class NewIssueWorker
include ApplicationWorker include ApplicationWorker
include NewIssuable include NewIssuable
feature_category :issue_tracking
def perform(issue_id, user_id) def perform(issue_id, user_id)
return unless objects_found?(issue_id, user_id) return unless objects_found?(issue_id, user_id)
......
...@@ -4,6 +4,8 @@ class NewMergeRequestWorker ...@@ -4,6 +4,8 @@ class NewMergeRequestWorker
include ApplicationWorker include ApplicationWorker
include NewIssuable include NewIssuable
feature_category :source_code_management
def perform(merge_request_id, user_id) def perform(merge_request_id, user_id)
return unless objects_found?(merge_request_id, user_id) return unless objects_found?(merge_request_id, user_id)
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
class NewNoteWorker class NewNoteWorker
include ApplicationWorker include ApplicationWorker
feature_category :issue_tracking
# Keep extra parameter to preserve backwards compatibility with # Keep extra parameter to preserve backwards compatibility with
# old `NewNoteWorker` jobs (can remove later) # old `NewNoteWorker` jobs (can remove later)
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
......
...@@ -4,6 +4,7 @@ class NewReleaseWorker ...@@ -4,6 +4,7 @@ class NewReleaseWorker
include ApplicationWorker include ApplicationWorker
queue_namespace :notifications queue_namespace :notifications
feature_category :release_orchestration
def perform(release_id) def perform(release_id)
release = Release.with_project_and_namespace.find_by_id(release_id) release = Release.with_project_and_namespace.find_by_id(release_id)
......
...@@ -6,6 +6,7 @@ module ObjectStorage ...@@ -6,6 +6,7 @@ module ObjectStorage
include ObjectStorageQueue include ObjectStorageQueue
sidekiq_options retry: 5 sidekiq_options retry: 5
feature_category_not_owned!
def perform(uploader_class_name, subject_class_name, file_field, subject_id) def perform(uploader_class_name, subject_class_name, file_field, subject_id)
uploader_class = uploader_class_name.constantize uploader_class = uploader_class_name.constantize
......
...@@ -5,6 +5,8 @@ module ObjectStorage ...@@ -5,6 +5,8 @@ module ObjectStorage
include ApplicationWorker include ApplicationWorker
include ObjectStorageQueue include ObjectStorageQueue
feature_category_not_owned!
SanityCheckError = Class.new(StandardError) SanityCheckError = Class.new(StandardError)
class MigrationResult class MigrationResult
......
...@@ -4,6 +4,8 @@ class PagesDomainRemovalCronWorker ...@@ -4,6 +4,8 @@ class PagesDomainRemovalCronWorker
include ApplicationWorker include ApplicationWorker
include CronjobQueue include CronjobQueue
feature_category :pages
def perform def perform
PagesDomain.for_removal.find_each do |domain| PagesDomain.for_removal.find_each do |domain|
domain.destroy! domain.destroy!
......
...@@ -4,6 +4,8 @@ class PagesDomainSslRenewalCronWorker ...@@ -4,6 +4,8 @@ class PagesDomainSslRenewalCronWorker
include ApplicationWorker include ApplicationWorker
include CronjobQueue include CronjobQueue
feature_category :pages
def perform def perform
return unless ::Gitlab::LetsEncrypt.enabled? return unless ::Gitlab::LetsEncrypt.enabled?
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
class PagesDomainSslRenewalWorker class PagesDomainSslRenewalWorker
include ApplicationWorker include ApplicationWorker
feature_category :pages
def perform(domain_id) def perform(domain_id)
domain = PagesDomain.find_by_id(domain_id) domain = PagesDomain.find_by_id(domain_id)
return unless domain&.enabled? return unless domain&.enabled?
......
...@@ -4,6 +4,8 @@ class PagesDomainVerificationCronWorker ...@@ -4,6 +4,8 @@ class PagesDomainVerificationCronWorker
include ApplicationWorker include ApplicationWorker
include CronjobQueue include CronjobQueue
feature_category :pages
def perform def perform
return if Gitlab::Database.read_only? return if Gitlab::Database.read_only?
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
class PagesDomainVerificationWorker class PagesDomainVerificationWorker
include ApplicationWorker include ApplicationWorker
feature_category :pages
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def perform(domain_id) def perform(domain_id)
return if Gitlab::Database.read_only? return if Gitlab::Database.read_only?
......
...@@ -4,6 +4,7 @@ class PagesWorker ...@@ -4,6 +4,7 @@ class PagesWorker
include ApplicationWorker include ApplicationWorker
sidekiq_options retry: 3 sidekiq_options retry: 3
feature_category :pages
def perform(action, *arg) def perform(action, *arg)
send(action, *arg) # rubocop:disable GitlabSecurity/PublicSend send(action, *arg) # rubocop:disable GitlabSecurity/PublicSend
......
...@@ -5,6 +5,7 @@ class PipelineProcessWorker ...@@ -5,6 +5,7 @@ class PipelineProcessWorker
include PipelineQueue include PipelineQueue
queue_namespace :pipeline_processing queue_namespace :pipeline_processing
feature_category :continuous_integration
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def perform(pipeline_id, build_ids = nil) def perform(pipeline_id, build_ids = nil)
......
...@@ -4,6 +4,8 @@ class PipelineScheduleWorker ...@@ -4,6 +4,8 @@ class PipelineScheduleWorker
include ApplicationWorker include ApplicationWorker
include CronjobQueue include CronjobQueue
feature_category :continuous_integration
def perform def perform
Ci::PipelineSchedule.runnable_schedules.preloaded.find_in_batches do |schedules| Ci::PipelineSchedule.runnable_schedules.preloaded.find_in_batches do |schedules|
schedules.each do |schedule| schedules.each do |schedule|
......
...@@ -4,6 +4,7 @@ class PluginWorker ...@@ -4,6 +4,7 @@ class PluginWorker
include ApplicationWorker include ApplicationWorker
sidekiq_options retry: false sidekiq_options retry: false
feature_category :integrations
def perform(file_name, data) def perform(file_name, data)
success, message = Gitlab::Plugin.execute(file_name, data) success, message = Gitlab::Plugin.execute(file_name, data)
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
class PostReceive class PostReceive
include ApplicationWorker include ApplicationWorker
feature_category :source_code_management
def perform(gl_repository, identifier, changes, push_options = {}) def perform(gl_repository, identifier, changes, push_options = {})
project, repo_type = Gitlab::GlRepository.parse(gl_repository) project, repo_type = Gitlab::GlRepository.parse(gl_repository)
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
class ProcessCommitWorker class ProcessCommitWorker
include ApplicationWorker include ApplicationWorker
feature_category :source_code_management
# project_id - The ID of the project this commit belongs to. # project_id - The ID of the project this commit belongs to.
# user_id - The ID of the user that pushed the commit. # user_id - The ID of the user that pushed the commit.
# commit_hash - Hash containing commit details to use for constructing a # commit_hash - Hash containing commit details to use for constructing a
......
...@@ -5,6 +5,8 @@ class ProjectCacheWorker ...@@ -5,6 +5,8 @@ class ProjectCacheWorker
include ApplicationWorker include ApplicationWorker
LEASE_TIMEOUT = 15.minutes.to_i LEASE_TIMEOUT = 15.minutes.to_i
feature_category :source_code_management
# project_id - The ID of the project for which to flush the cache. # project_id - The ID of the project for which to flush the cache.
# files - An Array containing extra types of files to refresh such as # files - An Array containing extra types of files to refresh such as
# `:readme` to flush the README and `:changelog` to flush the # `:readme` to flush the README and `:changelog` to flush the
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
class ProjectDailyStatisticsWorker class ProjectDailyStatisticsWorker
include ApplicationWorker include ApplicationWorker
feature_category :source_code_management
def perform(project_id) def perform(project_id)
project = Project.find_by_id(project_id) project = Project.find_by_id(project_id)
......
...@@ -4,6 +4,8 @@ class ProjectDestroyWorker ...@@ -4,6 +4,8 @@ class ProjectDestroyWorker
include ApplicationWorker include ApplicationWorker
include ExceptionBacktrace include ExceptionBacktrace
feature_category :source_code_management
def perform(project_id, user_id, params) def perform(project_id, user_id, params)
project = Project.find(project_id) project = Project.find(project_id)
user = User.find(user_id) user = User.find(user_id)
......
...@@ -5,6 +5,7 @@ class ProjectExportWorker ...@@ -5,6 +5,7 @@ class ProjectExportWorker
include ExceptionBacktrace include ExceptionBacktrace
sidekiq_options retry: 3 sidekiq_options retry: 3
feature_category :source_code_management
def perform(current_user_id, project_id, after_export_strategy = {}, params = {}) def perform(current_user_id, project_id, after_export_strategy = {}, params = {})
current_user = User.find(current_user_id) current_user = User.find(current_user_id)
......
...@@ -4,6 +4,7 @@ class ProjectServiceWorker ...@@ -4,6 +4,7 @@ class ProjectServiceWorker
include ApplicationWorker include ApplicationWorker
sidekiq_options dead: false sidekiq_options dead: false
feature_category :integrations
def perform(hook_id, data) def perform(hook_id, data)
data = data.with_indifferent_access data = data.with_indifferent_access
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
class PropagateServiceTemplateWorker class PropagateServiceTemplateWorker
include ApplicationWorker include ApplicationWorker
feature_category :source_code_management
LEASE_TIMEOUT = 4.hours.to_i LEASE_TIMEOUT = 4.hours.to_i
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
......
...@@ -4,6 +4,8 @@ class PruneOldEventsWorker ...@@ -4,6 +4,8 @@ class PruneOldEventsWorker
include ApplicationWorker include ApplicationWorker
include CronjobQueue include CronjobQueue
feature_category_not_owned!
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def perform def perform
# Contribution calendar shows maximum 12 months of events, we retain 3 years for data integrity. # Contribution calendar shows maximum 12 months of events, we retain 3 years for data integrity.
......
...@@ -6,6 +6,8 @@ class PruneWebHookLogsWorker ...@@ -6,6 +6,8 @@ class PruneWebHookLogsWorker
include ApplicationWorker include ApplicationWorker
include CronjobQueue include CronjobQueue
feature_category :integrations
# The maximum number of rows to remove in a single job. # The maximum number of rows to remove in a single job.
DELETE_LIMIT = 50_000 DELETE_LIMIT = 50_000
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
class ReactiveCachingWorker class ReactiveCachingWorker
include ApplicationWorker include ApplicationWorker
feature_category_not_owned!
def perform(class_name, id, *args) def perform(class_name, id, *args)
klass = begin klass = begin
class_name.constantize class_name.constantize
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
class RebaseWorker class RebaseWorker
include ApplicationWorker include ApplicationWorker
feature_category :source_code_management
def perform(merge_request_id, current_user_id) def perform(merge_request_id, current_user_id)
current_user = User.find(current_user_id) current_user = User.find(current_user_id)
merge_request = MergeRequest.find(merge_request_id) merge_request = MergeRequest.find(merge_request_id)
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
class RemoteMirrorNotificationWorker class RemoteMirrorNotificationWorker
include ApplicationWorker include ApplicationWorker
feature_category :source_code_management
def perform(remote_mirror_id) def perform(remote_mirror_id)
remote_mirror = RemoteMirror.find_by_id(remote_mirror_id) remote_mirror = RemoteMirror.find_by_id(remote_mirror_id)
......
...@@ -4,6 +4,8 @@ class RemoveExpiredGroupLinksWorker ...@@ -4,6 +4,8 @@ class RemoveExpiredGroupLinksWorker
include ApplicationWorker include ApplicationWorker
include CronjobQueue include CronjobQueue
feature_category :authentication_and_authorization
def perform def perform
ProjectGroupLink.expired.destroy_all # rubocop: disable DestroyAll ProjectGroupLink.expired.destroy_all # rubocop: disable DestroyAll
end end
......
...@@ -4,6 +4,8 @@ class RemoveExpiredMembersWorker ...@@ -4,6 +4,8 @@ class RemoveExpiredMembersWorker
include ApplicationWorker include ApplicationWorker
include CronjobQueue include CronjobQueue
feature_category :authentication_and_authorization
def perform def perform
Member.expired.find_each do |member| Member.expired.find_each do |member|
Members::DestroyService.new.execute(member, skip_authorization: true) Members::DestroyService.new.execute(member, skip_authorization: true)
......
...@@ -4,6 +4,8 @@ class RemoveUnreferencedLfsObjectsWorker ...@@ -4,6 +4,8 @@ class RemoveUnreferencedLfsObjectsWorker
include ApplicationWorker include ApplicationWorker
include CronjobQueue include CronjobQueue
feature_category :source_code_management
def perform def perform
LfsObject.destroy_unreferenced LfsObject.destroy_unreferenced
end end
......
...@@ -4,6 +4,8 @@ class RepositoryArchiveCacheWorker ...@@ -4,6 +4,8 @@ class RepositoryArchiveCacheWorker
include ApplicationWorker include ApplicationWorker
include CronjobQueue include CronjobQueue
feature_category :source_code_management
def perform def perform
RepositoryArchiveCleanUpService.new.execute RepositoryArchiveCleanUpService.new.execute
end end
......
...@@ -7,6 +7,8 @@ module RepositoryCheck ...@@ -7,6 +7,8 @@ module RepositoryCheck
include ::EachShardWorker include ::EachShardWorker
include ExclusiveLeaseGuard include ExclusiveLeaseGuard
feature_category :source_code_management
LEASE_TIMEOUT = 1.hour LEASE_TIMEOUT = 1.hour
def perform def perform
......
...@@ -4,6 +4,7 @@ class RepositoryCleanupWorker ...@@ -4,6 +4,7 @@ class RepositoryCleanupWorker
include ApplicationWorker include ApplicationWorker
sidekiq_options retry: 3 sidekiq_options retry: 3
feature_category :source_code_management
sidekiq_retries_exhausted do |msg, err| sidekiq_retries_exhausted do |msg, err|
next if err.is_a?(ActiveRecord::RecordNotFound) next if err.is_a?(ActiveRecord::RecordNotFound)
......
...@@ -6,6 +6,8 @@ class RepositoryForkWorker ...@@ -6,6 +6,8 @@ class RepositoryForkWorker
include ProjectStartImport include ProjectStartImport
include ProjectImportOptions include ProjectImportOptions
feature_category :source_code_management
def perform(*args) def perform(*args)
target_project_id = args.shift target_project_id = args.shift
target_project = Project.find(target_project_id) target_project = Project.find(target_project_id)
......
...@@ -6,6 +6,8 @@ class RepositoryImportWorker ...@@ -6,6 +6,8 @@ class RepositoryImportWorker
include ProjectStartImport include ProjectStartImport
include ProjectImportOptions include ProjectImportOptions
feature_category :importers
# technical debt: https://gitlab.com/gitlab-org/gitlab/issues/33991 # technical debt: https://gitlab.com/gitlab-org/gitlab/issues/33991
sidekiq_options memory_killer_memory_growth_kb: ENV.fetch('MEMORY_KILLER_REPOSITORY_IMPORT_WORKER_MEMORY_GROWTH_KB', 50).to_i sidekiq_options memory_killer_memory_growth_kb: ENV.fetch('MEMORY_KILLER_REPOSITORY_IMPORT_WORKER_MEMORY_GROWTH_KB', 50).to_i
sidekiq_options memory_killer_max_memory_growth_kb: ENV.fetch('MEMORY_KILLER_REPOSITORY_IMPORT_WORKER_MAX_MEMORY_GROWTH_KB', 300_000).to_i sidekiq_options memory_killer_max_memory_growth_kb: ENV.fetch('MEMORY_KILLER_REPOSITORY_IMPORT_WORKER_MAX_MEMORY_GROWTH_KB', 300_000).to_i
......
...@@ -4,6 +4,8 @@ class RepositoryRemoveRemoteWorker ...@@ -4,6 +4,8 @@ class RepositoryRemoveRemoteWorker
include ApplicationWorker include ApplicationWorker
include ExclusiveLeaseGuard include ExclusiveLeaseGuard
feature_category :source_code_management
LEASE_TIMEOUT = 1.hour LEASE_TIMEOUT = 1.hour
attr_reader :project, :remote_name attr_reader :project, :remote_name
......
...@@ -7,6 +7,7 @@ class RepositoryUpdateRemoteMirrorWorker ...@@ -7,6 +7,7 @@ class RepositoryUpdateRemoteMirrorWorker
include Gitlab::ExclusiveLeaseHelpers include Gitlab::ExclusiveLeaseHelpers
sidekiq_options retry: 3, dead: false sidekiq_options retry: 3, dead: false
feature_category :source_code_management
LOCK_WAIT_TIME = 30.seconds LOCK_WAIT_TIME = 30.seconds
MAX_TRIES = 3 MAX_TRIES = 3
......
...@@ -4,6 +4,8 @@ class RequestsProfilesWorker ...@@ -4,6 +4,8 @@ class RequestsProfilesWorker
include ApplicationWorker include ApplicationWorker
include CronjobQueue include CronjobQueue
feature_category :source_code_management
def perform def perform
Gitlab::RequestProfiler.remove_all_profiles Gitlab::RequestProfiler.remove_all_profiles
end end
......
...@@ -5,6 +5,7 @@ class RunPipelineScheduleWorker ...@@ -5,6 +5,7 @@ class RunPipelineScheduleWorker
include PipelineQueue include PipelineQueue
queue_namespace :pipeline_creation queue_namespace :pipeline_creation
feature_category :continuous_integration
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def perform(schedule_id, user_id) def perform(schedule_id, user_id)
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment