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:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-01-13 18:14:46 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-01-13 18:14:46 +0300
commitbd5ff5cb6553dd8f168b28c97175a63250fe2ab2 (patch)
treec51bd4b3144c48e43d2109e589b339d710e929c7 /lib/gitlab/ci/pipeline
parenta00537e412e4ef6761ad35cc7148637ad75434a1 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/ci/pipeline')
-rw-r--r--lib/gitlab/ci/pipeline/chain/create.rb46
1 files changed, 20 insertions, 26 deletions
diff --git a/lib/gitlab/ci/pipeline/chain/create.rb b/lib/gitlab/ci/pipeline/chain/create.rb
index a2fac144d45..54b54bd0514 100644
--- a/lib/gitlab/ci/pipeline/chain/create.rb
+++ b/lib/gitlab/ci/pipeline/chain/create.rb
@@ -11,11 +11,11 @@ module Gitlab
def perform!
logger.instrument_with_sql(:pipeline_save) do
BulkInsertableAssociations.with_bulk_insert do
- tags = extract_tag_list_by_status
-
- pipeline.transaction do
- pipeline.save!
- CommitStatus.bulk_insert_tags!(statuses, tags) if bulk_insert_tags?
+ with_bulk_insert_tags do
+ pipeline.transaction do
+ pipeline.save!
+ CommitStatus.bulk_insert_tags!(statuses) if bulk_insert_tags?
+ end
end
end
end
@@ -29,32 +29,26 @@ module Gitlab
private
- def statuses
- strong_memoize(:statuses) do
- pipeline.stages.flat_map(&:statuses)
+ def bulk_insert_tags?
+ strong_memoize(:bulk_insert_tags) do
+ ::Feature.enabled?(:ci_bulk_insert_tags, project, default_enabled: :yaml)
end
end
- # We call `job.tag_list=` to assign tags to the jobs from the
- # Chain::Seed step which uses the `@tag_list` instance variable to
- # store them on the record. We remove them here because we want to
- # bulk insert them, otherwise they would be inserted and assigned one
- # by one with callbacks. We must use `remove_instance_variable`
- # because having the instance variable defined would still run the callbacks
- def extract_tag_list_by_status
- return {} unless bulk_insert_tags?
-
- statuses.each.with_object({}) do |job, acc|
- tag_list = job.clear_memoization(:tag_list)
- next unless tag_list
-
- acc[job.name] = tag_list
- end
+ def with_bulk_insert_tags
+ previous = Thread.current['ci_bulk_insert_tags']
+ Thread.current['ci_bulk_insert_tags'] = bulk_insert_tags?
+ yield
+ ensure
+ Thread.current['ci_bulk_insert_tags'] = previous
end
- def bulk_insert_tags?
- strong_memoize(:bulk_insert_tags) do
- ::Feature.enabled?(:ci_bulk_insert_tags, project, default_enabled: :yaml)
+ def statuses
+ strong_memoize(:statuses) do
+ pipeline
+ .stages
+ .flat_map(&:statuses)
+ .select { |status| status.respond_to?(:tag_list) }
end
end
end