Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/services/user_project_access_changed_service.rb')
-rw-r--r--app/services/user_project_access_changed_service.rb16
1 files changed, 14 insertions, 2 deletions
diff --git a/app/services/user_project_access_changed_service.rb b/app/services/user_project_access_changed_service.rb
index f52502e0379..5f48f410bf7 100644
--- a/app/services/user_project_access_changed_service.rb
+++ b/app/services/user_project_access_changed_service.rb
@@ -20,8 +20,13 @@ class UserProjectAccessChangedService
if priority == HIGH_PRIORITY
AuthorizedProjectsWorker.bulk_perform_async(bulk_args) # rubocop:disable Scalability/BulkPerformWithContext
else
- AuthorizedProjectUpdate::UserRefreshFromReplicaWorker.bulk_perform_in( # rubocop:disable Scalability/BulkPerformWithContext
- DELAY, bulk_args, batch_size: 100, batch_delay: 30.seconds)
+ with_related_class_context do
+ # We wrap the execution in `with_related_class_context`so as to obtain
+ # the location of the original caller
+ # in jobs enqueued from within `AuthorizedProjectUpdate::UserRefreshFromReplicaWorker`
+ AuthorizedProjectUpdate::UserRefreshFromReplicaWorker.bulk_perform_in( # rubocop:disable Scalability/BulkPerformWithContext
+ DELAY, bulk_args, batch_size: 100, batch_delay: 30.seconds)
+ end
end
end
@@ -29,4 +34,11 @@ class UserProjectAccessChangedService
result
end
+
+ private
+
+ def with_related_class_context(&block)
+ current_caller_id = Gitlab::ApplicationContext.current_context_attribute('meta.caller_id').presence
+ Gitlab::ApplicationContext.with_context(related_class: current_caller_id, &block)
+ end
end