summaryrefslogtreecommitdiff
path: root/app/workers/ci
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-07-06 15:08:14 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-07-06 15:08:14 +0000
commitb72b14cb4d1567c555d9e5cb336111afd479ee9e (patch)
tree7cc3087bae34b9dd9ce2339658d299cb4dae0ed9 /app/workers/ci
parentd5e68dfae835516bcc94d208cd7be461e75831ff (diff)
downloadgitlab-ce-b72b14cb4d1567c555d9e5cb336111afd479ee9e.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/workers/ci')
-rw-r--r--app/workers/ci/resource_groups/assign_resource_from_resource_group_worker.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/app/workers/ci/resource_groups/assign_resource_from_resource_group_worker.rb b/app/workers/ci/resource_groups/assign_resource_from_resource_group_worker.rb
index 15ed89fd00e..ad0ed3d16f1 100644
--- a/app/workers/ci/resource_groups/assign_resource_from_resource_group_worker.rb
+++ b/app/workers/ci/resource_groups/assign_resource_from_resource_group_worker.rb
@@ -2,7 +2,10 @@
module Ci
module ResourceGroups
- class AssignResourceFromResourceGroupWorker # rubocop:disable Scalability/IdempotentWorker
+ # This worker is to assign a resource to a pipeline job from a resource group
+ # and enqueue the job to be executed by a runner.
+ # See https://docs.gitlab.com/ee/ci/yaml/#resource_group for more information.
+ class AssignResourceFromResourceGroupWorker
include ApplicationWorker
sidekiq_options retry: 3
@@ -11,6 +14,13 @@ module Ci
queue_namespace :pipeline_processing
feature_category :continuous_delivery
+ # This worker is idempotent that it produces the same result
+ # as long as the same resource group id is passed as an argument.
+ # Therefore, we can deduplicate the sidekiq jobs until the on-going
+ # assignment process has been finished.
+ idempotent!
+ deduplicate :until_executed
+
def perform(resource_group_id)
::Ci::ResourceGroup.find_by_id(resource_group_id).try do |resource_group|
Ci::ResourceGroups::AssignResourceFromResourceGroupService.new(resource_group.project, nil)