Commit d7729955 authored by Bob Van Landuyt's avatar Bob Van Landuyt Committed by Alessio Caiazza

Explain cron-workers that don't need context

These workers don't need context because they don't operate scoped to
a user, namespace or project.
parent dd5500f1
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
class AdminEmailWorker class AdminEmailWorker
include ApplicationWorker include ApplicationWorker
include CronjobQueue # rubocop:disable Scalability/CronWorkerContext # rubocop:disable Scalability/CronWorkerContext
# This worker does not perform work scoped to a context
include CronjobQueue
# rubocop:enable Scalability/CronWorkerContext
feature_category_not_owned! feature_category_not_owned!
......
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
class ExpireBuildArtifactsWorker class ExpireBuildArtifactsWorker
include ApplicationWorker include ApplicationWorker
include CronjobQueue # rubocop:disable Scalability/CronWorkerContext # rubocop:disable Scalability/CronWorkerContext
# This worker does not perform work scoped to a context
include CronjobQueue
# rubocop:enable Scalability/CronWorkerContext
feature_category :continuous_integration feature_category :continuous_integration
......
...@@ -4,7 +4,10 @@ class GitlabUsagePingWorker ...@@ -4,7 +4,10 @@ class GitlabUsagePingWorker
LEASE_TIMEOUT = 86400 LEASE_TIMEOUT = 86400
include ApplicationWorker include ApplicationWorker
include CronjobQueue # rubocop:disable Scalability/CronWorkerContext # rubocop:disable Scalability/CronWorkerContext
# This worker does not perform work scoped to a context
include CronjobQueue
# rubocop:enable Scalability/CronWorkerContext
feature_category_not_owned! feature_category_not_owned!
......
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
class ImportExportProjectCleanupWorker class ImportExportProjectCleanupWorker
include ApplicationWorker include ApplicationWorker
include CronjobQueue # rubocop:disable Scalability/CronWorkerContext # rubocop:disable Scalability/CronWorkerContext
# This worker does not perform work scoped to a context
include CronjobQueue
# rubocop:enable Scalability/CronWorkerContext
feature_category :importers feature_category :importers
......
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
class PruneOldEventsWorker class PruneOldEventsWorker
include ApplicationWorker include ApplicationWorker
include CronjobQueue # rubocop:disable Scalability/CronWorkerContext # rubocop:disable Scalability/CronWorkerContext
# This worker does not perform work scoped to a context
include CronjobQueue
# rubocop:enable Scalability/CronWorkerContext
feature_category_not_owned! feature_category_not_owned!
......
...@@ -4,7 +4,10 @@ ...@@ -4,7 +4,10 @@
# table. # table.
class PruneWebHookLogsWorker class PruneWebHookLogsWorker
include ApplicationWorker include ApplicationWorker
include CronjobQueue # rubocop:disable Scalability/CronWorkerContext # rubocop:disable Scalability/CronWorkerContext
# This worker does not perform work scoped to a context
include CronjobQueue
# rubocop:enable Scalability/CronWorkerContext
feature_category :integrations feature_category :integrations
......
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
class RemoveUnreferencedLfsObjectsWorker class RemoveUnreferencedLfsObjectsWorker
include ApplicationWorker include ApplicationWorker
include CronjobQueue # rubocop:disable Scalability/CronWorkerContext # rubocop:disable Scalability/CronWorkerContext
# This worker does not perform work scoped to a context
include CronjobQueue
# rubocop:enable Scalability/CronWorkerContext
feature_category :git_lfs feature_category :git_lfs
......
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
class RepositoryArchiveCacheWorker class RepositoryArchiveCacheWorker
include ApplicationWorker include ApplicationWorker
include CronjobQueue # rubocop:disable Scalability/CronWorkerContext # rubocop:disable Scalability/CronWorkerContext
# This worker does not perform work scoped to a context
include CronjobQueue
# rubocop:enable Scalability/CronWorkerContext
feature_category :source_code_management feature_category :source_code_management
......
...@@ -3,7 +3,10 @@ ...@@ -3,7 +3,10 @@
module RepositoryCheck module RepositoryCheck
class DispatchWorker class DispatchWorker
include ApplicationWorker include ApplicationWorker
include CronjobQueue # rubocop:disable Scalability/CronWorkerContext # rubocop:disable Scalability/CronWorkerContext
# This worker does not perform work scoped to a context
include CronjobQueue
# rubocop:enable Scalability/CronWorkerContext
include ::EachShardWorker include ::EachShardWorker
include ExclusiveLeaseGuard include ExclusiveLeaseGuard
......
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
class RequestsProfilesWorker class RequestsProfilesWorker
include ApplicationWorker include ApplicationWorker
include CronjobQueue # rubocop:disable Scalability/CronWorkerContext # rubocop:disable Scalability/CronWorkerContext
# This worker does not perform work scoped to a context
include CronjobQueue
# rubocop:enable Scalability/CronWorkerContext
feature_category :source_code_management feature_category :source_code_management
......
...@@ -2,7 +2,11 @@ ...@@ -2,7 +2,11 @@
class StuckImportJobsWorker class StuckImportJobsWorker
include ApplicationWorker include ApplicationWorker
include CronjobQueue # rubocop:disable Scalability/CronWorkerContext # rubocop:disable Scalability/CronWorkerContext
# This worker updates several import states inline and does not schedule
# other jobs. So no context needed
include CronjobQueue
# rubocop:enable Scalability/CronWorkerContext
feature_category :importers feature_category :importers
worker_resource_boundary :cpu worker_resource_boundary :cpu
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
class TrendingProjectsWorker class TrendingProjectsWorker
include ApplicationWorker include ApplicationWorker
# rubocop:disable Scalability/CronWorkerContext
# This worker does not perform work scoped to a context
include CronjobQueue
# rubocop:enable Scalability/CronWorkerContext
include CronjobQueue # rubocop:disable Scalability/CronWorkerContext include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
feature_category :source_code_management feature_category :source_code_management
......
...@@ -4,8 +4,11 @@ class ClearSharedRunnersMinutesWorker ...@@ -4,8 +4,11 @@ class ClearSharedRunnersMinutesWorker
LEASE_TIMEOUT = 3600 LEASE_TIMEOUT = 3600
include ApplicationWorker include ApplicationWorker
include CronjobQueue # rubocop:disable Scalability/CronWorkerContext # rubocop:disable Scalability/CronWorkerContext
# This worker does not perform work scoped to a context
# all queries are scoped across multiple namespaces
include CronjobQueue
# rubocop:enable Scalability/CronWorkerContext
feature_category :continuous_integration feature_category :continuous_integration
def perform def perform
......
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
module Geo module Geo
class ContainerRepositorySyncDispatchWorker < Geo::Scheduler::Secondary::SchedulerWorker class ContainerRepositorySyncDispatchWorker < Geo::Scheduler::Secondary::SchedulerWorker
include CronjobQueue # rubocop:disable Scalability/CronWorkerContext # rubocop:disable Scalability/CronWorkerContext
# This worker does not perform work scoped to a context
include CronjobQueue
# rubocop:enable Scalability/CronWorkerContext
def perform def perform
unless Gitlab.config.geo.registry_replication.enabled unless Gitlab.config.geo.registry_replication.enabled
......
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
module Geo module Geo
class FileDownloadDispatchWorker < Geo::Scheduler::Secondary::SchedulerWorker class FileDownloadDispatchWorker < Geo::Scheduler::Secondary::SchedulerWorker
include CronjobQueue # rubocop:disable Scalability/CronWorkerContext # rubocop:disable Scalability/CronWorkerContext
# This worker does not perform work scoped to a context
include CronjobQueue
# rubocop:enable Scalability/CronWorkerContext
private private
......
...@@ -4,7 +4,10 @@ module Geo ...@@ -4,7 +4,10 @@ module Geo
class MetricsUpdateWorker class MetricsUpdateWorker
include ApplicationWorker include ApplicationWorker
include ExclusiveLeaseGuard include ExclusiveLeaseGuard
include CronjobQueue # rubocop:disable Scalability/CronWorkerContext # rubocop:disable Scalability/CronWorkerContext
# This worker does not perform work scoped to a context
include CronjobQueue
# rubocop:enable Scalability/CronWorkerContext
feature_category :geo_replication feature_category :geo_replication
......
...@@ -3,7 +3,10 @@ ...@@ -3,7 +3,10 @@
module Geo module Geo
class PruneEventLogWorker class PruneEventLogWorker
include ApplicationWorker include ApplicationWorker
include CronjobQueue # rubocop:disable Scalability/CronWorkerContext # rubocop:disable Scalability/CronWorkerContext
# This worker does not perform work scoped to a context
include CronjobQueue
# rubocop:enable Scalability/CronWorkerContext
include ::Gitlab::Utils::StrongMemoize include ::Gitlab::Utils::StrongMemoize
include ::Gitlab::Geo::LogHelpers include ::Gitlab::Geo::LogHelpers
......
...@@ -4,7 +4,10 @@ module Geo ...@@ -4,7 +4,10 @@ module Geo
module RepositoryVerification module RepositoryVerification
module Secondary module Secondary
class ShardWorker < Geo::Scheduler::Secondary::SchedulerWorker class ShardWorker < Geo::Scheduler::Secondary::SchedulerWorker
include CronjobQueue # rubocop:disable Scalability/CronWorkerContext # rubocop:disable Scalability/CronWorkerContext
# This worker does not perform work scoped to a context
include CronjobQueue
# rubocop:enable Scalability/CronWorkerContext
attr_accessor :shard_name attr_accessor :shard_name
def perform(shard_name) def perform(shard_name)
......
...@@ -4,7 +4,10 @@ module Geo ...@@ -4,7 +4,10 @@ module Geo
module Scheduler module Scheduler
class PerShardSchedulerWorker class PerShardSchedulerWorker
include ApplicationWorker include ApplicationWorker
include CronjobQueue # rubocop:disable Scalability/CronWorkerContext # rubocop:disable Scalability/CronWorkerContext
# This worker does not perform work scoped to a context
include CronjobQueue
# rubocop:enable Scalability/CronWorkerContext
include ::Gitlab::Geo::LogHelpers include ::Gitlab::Geo::LogHelpers
include ::EachShardWorker include ::EachShardWorker
......
...@@ -3,7 +3,10 @@ ...@@ -3,7 +3,10 @@
module Geo module Geo
class SidekiqCronConfigWorker class SidekiqCronConfigWorker
include ApplicationWorker include ApplicationWorker
include CronjobQueue # rubocop:disable Scalability/CronWorkerContext # rubocop:disable Scalability/CronWorkerContext
# This worker does not perform work scoped to a context
include CronjobQueue
# rubocop:enable Scalability/CronWorkerContext
feature_category :geo_replication feature_category :geo_replication
......
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
class HistoricalDataWorker class HistoricalDataWorker
include ApplicationWorker include ApplicationWorker
include CronjobQueue # rubocop:disable Scalability/CronWorkerContext # rubocop:disable Scalability/CronWorkerContext
# This worker does not perform work scoped to a context
include CronjobQueue
# rubocop:enable Scalability/CronWorkerContext
feature_category :license_compliance feature_category :license_compliance
......
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
class LdapAllGroupsSyncWorker class LdapAllGroupsSyncWorker
include ApplicationWorker include ApplicationWorker
include CronjobQueue # rubocop:disable Scalability/CronWorkerContext # rubocop:disable Scalability/CronWorkerContext
# This worker does not perform work scoped to a context
include CronjobQueue
# rubocop:enable Scalability/CronWorkerContext
feature_category :authentication_and_authorization feature_category :authentication_and_authorization
worker_has_external_dependencies! worker_has_external_dependencies!
......
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
class PseudonymizerWorker class PseudonymizerWorker
include ApplicationWorker include ApplicationWorker
include CronjobQueue # rubocop:disable Scalability/CronWorkerContext # rubocop:disable Scalability/CronWorkerContext
# This worker does not perform work scoped to a context
include CronjobQueue
# rubocop:enable Scalability/CronWorkerContext
feature_category :integrations feature_category :integrations
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
class UpdateAllMirrorsWorker class UpdateAllMirrorsWorker
include ApplicationWorker include ApplicationWorker
include CronjobQueue # rubocop:disable Scalability/CronWorkerContext include CronjobQueue
feature_category :source_code_management feature_category :source_code_management
......
...@@ -23,7 +23,7 @@ module RuboCop ...@@ -23,7 +23,7 @@ module RuboCop
PATTERN PATTERN
def_node_search :schedules_with_batch_context?, <<~PATTERN def_node_search :schedules_with_batch_context?, <<~PATTERN
(send (...) {:bulk_perform_async_with_contexts :bulk_perform_in_with_contexts} (...)) (send (...) {:bulk_perform_async_with_contexts :bulk_perform_in_with_contexts} _*)
PATTERN PATTERN
def on_send(node) def on_send(node)
......
...@@ -58,7 +58,9 @@ describe RuboCop::Cop::Scalability::CronWorkerContext do ...@@ -58,7 +58,9 @@ describe RuboCop::Cop::Scalability::CronWorkerContext do
include CronjobQueue include CronjobQueue
def perform def perform
SomeOtherWorker.bulk_perform_async_with_contexts(contexts_for_arguments) SomeOtherWorker.bulk_perform_async_with_contexts(things,
arguments_proc: -> (thing) { thing.id },
context_proc: -> (thing) { { project: thing.project } })
end end
end end
CODE CODE
...@@ -70,7 +72,9 @@ describe RuboCop::Cop::Scalability::CronWorkerContext do ...@@ -70,7 +72,9 @@ describe RuboCop::Cop::Scalability::CronWorkerContext do
include CronjobQueue include CronjobQueue
def perform def perform
SomeOtherWorker.bulk_perform_in_with_contexts(contexts_for_arguments) SomeOtherWorker.bulk_perform_in_with_contexts(10.minutes, things,
arguments_proc: -> (thing) { thing.id },
context_proc: -> (thing) { { project: thing.project } })
end end
end end
CODE CODE
......
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