Commit ad751861 authored by Alessio Caiazza's avatar Alessio Caiazza

Merge branch 'bvl-explain-contextless-workers' into 'master'

Explain cron-workers that don't need context

See merge request gitlab-org/gitlab!24494
parents b3a26657 d7729955
......@@ -2,7 +2,10 @@
class AdminEmailWorker
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!
......
......@@ -2,7 +2,10 @@
class ExpireBuildArtifactsWorker
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
......
......@@ -4,7 +4,10 @@ class GitlabUsagePingWorker
LEASE_TIMEOUT = 86400
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!
......
......@@ -2,7 +2,10 @@
class ImportExportProjectCleanupWorker
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
......
......@@ -2,7 +2,10 @@
class PruneOldEventsWorker
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!
......
......@@ -4,7 +4,10 @@
# table.
class PruneWebHookLogsWorker
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
......
......@@ -2,7 +2,10 @@
class RemoveUnreferencedLfsObjectsWorker
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
......
......@@ -2,7 +2,10 @@
class RepositoryArchiveCacheWorker
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
......
......@@ -3,7 +3,10 @@
module RepositoryCheck
class DispatchWorker
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 ExclusiveLeaseGuard
......
......@@ -2,7 +2,10 @@
class RequestsProfilesWorker
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
......
......@@ -2,7 +2,11 @@
class StuckImportJobsWorker
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
worker_resource_boundary :cpu
......
......@@ -2,6 +2,10 @@
class TrendingProjectsWorker
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
feature_category :source_code_management
......
......@@ -4,8 +4,11 @@ class ClearSharedRunnersMinutesWorker
LEASE_TIMEOUT = 3600
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
def perform
......
......@@ -2,7 +2,10 @@
module Geo
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
unless Gitlab.config.geo.registry_replication.enabled
......
......@@ -2,7 +2,10 @@
module Geo
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
......
......@@ -4,7 +4,10 @@ module Geo
class MetricsUpdateWorker
include ApplicationWorker
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
......
......@@ -3,7 +3,10 @@
module Geo
class PruneEventLogWorker
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::Geo::LogHelpers
......
......@@ -4,7 +4,10 @@ module Geo
module RepositoryVerification
module Secondary
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
def perform(shard_name)
......
......@@ -4,7 +4,10 @@ module Geo
module Scheduler
class PerShardSchedulerWorker
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 ::EachShardWorker
......
......@@ -3,7 +3,10 @@
module Geo
class SidekiqCronConfigWorker
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
......
......@@ -2,7 +2,10 @@
class HistoricalDataWorker
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
......
......@@ -2,7 +2,10 @@
class LdapAllGroupsSyncWorker
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
worker_has_external_dependencies!
......
......@@ -2,7 +2,10 @@
class PseudonymizerWorker
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
......
......@@ -2,7 +2,7 @@
class UpdateAllMirrorsWorker
include ApplicationWorker
include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
include CronjobQueue
feature_category :source_code_management
......
......@@ -23,7 +23,7 @@ module RuboCop
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
def on_send(node)
......
......@@ -58,7 +58,9 @@ describe RuboCop::Cop::Scalability::CronWorkerContext do
include CronjobQueue
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
CODE
......@@ -70,7 +72,9 @@ describe RuboCop::Cop::Scalability::CronWorkerContext do
include CronjobQueue
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
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