diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-06 15:08:14 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-06 15:08:14 +0000 |
commit | b72b14cb4d1567c555d9e5cb336111afd479ee9e (patch) | |
tree | 7cc3087bae34b9dd9ce2339658d299cb4dae0ed9 /app/workers/ci | |
parent | d5e68dfae835516bcc94d208cd7be461e75831ff (diff) | |
download | gitlab-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.rb | 12 |
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) |