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>2023-09-05 16:47:14 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-09-05 16:47:14 +0300
commit022f9b6b0c3771d0c8f1c4cb5d15258119fddc2a (patch)
tree4c205cedfd196fb0fe23a794bc6effb8f8d6ef21
parent88bbc405d6b46a477d6dddf4f1416240640f70d1 (diff)
Add latest changes from gitlab-org/gitlab@16-3-stable-ee
-rw-r--r--app/workers/all_queues.yml9
-rw-r--r--app/workers/ci/initialize_pipelines_iid_sequence_worker.rb19
-rw-r--r--config/sidekiq_queues.yml2
-rw-r--r--lib/gitlab/event_store.rb1
-rw-r--r--spec/workers/ci/initialize_pipelines_iid_sequence_worker_spec.rb38
5 files changed, 69 insertions, 0 deletions
diff --git a/app/workers/all_queues.yml b/app/workers/all_queues.yml
index 1664add1ac9..60f233b8289 100644
--- a/app/workers/all_queues.yml
+++ b/app/workers/all_queues.yml
@@ -2541,6 +2541,15 @@
:weight: 1
:idempotent: true
:tags: []
+- :name: ci_initialize_pipelines_iid_sequence
+ :worker_name: Ci::InitializePipelinesIidSequenceWorker
+ :feature_category: :continuous_integration
+ :has_external_dependencies: false
+ :urgency: :low
+ :resource_boundary: :unknown
+ :weight: 1
+ :idempotent: true
+ :tags: []
- :name: ci_job_artifacts_expire_project_build_artifacts
:worker_name: Ci::JobArtifacts::ExpireProjectBuildArtifactsWorker
:feature_category: :build_artifacts
diff --git a/app/workers/ci/initialize_pipelines_iid_sequence_worker.rb b/app/workers/ci/initialize_pipelines_iid_sequence_worker.rb
new file mode 100644
index 00000000000..95b58814e08
--- /dev/null
+++ b/app/workers/ci/initialize_pipelines_iid_sequence_worker.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+module Ci
+ class InitializePipelinesIidSequenceWorker
+ include Gitlab::EventStore::Subscriber
+
+ data_consistency :always
+ feature_category :continuous_integration
+ idempotent!
+
+ def handle_event(event)
+ Project.find_by_id(event.data[:project_id]).try do |project|
+ next if project.internal_ids.ci_pipelines.any?
+
+ ::Ci::Pipeline.track_project_iid!(project, 0)
+ end
+ end
+ end
+end
diff --git a/config/sidekiq_queues.yml b/config/sidekiq_queues.yml
index 260cdeb27d6..d494f8618b1 100644
--- a/config/sidekiq_queues.yml
+++ b/config/sidekiq_queues.yml
@@ -125,6 +125,8 @@
- 1
- - ci_delete_objects
- 1
+- - ci_initialize_pipelines_iid_sequence
+ - 1
- - ci_job_artifacts_expire_project_build_artifacts
- 1
- - ci_llm_generate_config
diff --git a/lib/gitlab/event_store.rb b/lib/gitlab/event_store.rb
index ce71ee594f2..474aac8073e 100644
--- a/lib/gitlab/event_store.rb
+++ b/lib/gitlab/event_store.rb
@@ -64,6 +64,7 @@ module Gitlab
store.subscribe ::Ml::ExperimentTracking::AssociateMlCandidateToPackageWorker,
to: ::Packages::PackageCreatedEvent,
if: -> (event) { ::Ml::ExperimentTracking::AssociateMlCandidateToPackageWorker.handles_event?(event) }
+ store.subscribe ::Ci::InitializePipelinesIidSequenceWorker, to: ::Projects::ProjectCreatedEvent
end
private_class_method :configure!
end
diff --git a/spec/workers/ci/initialize_pipelines_iid_sequence_worker_spec.rb b/spec/workers/ci/initialize_pipelines_iid_sequence_worker_spec.rb
new file mode 100644
index 00000000000..fcf57e21ac9
--- /dev/null
+++ b/spec/workers/ci/initialize_pipelines_iid_sequence_worker_spec.rb
@@ -0,0 +1,38 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Ci::InitializePipelinesIidSequenceWorker, feature_category: :continuous_integration do
+ let_it_be_with_refind(:project) { create(:project) }
+
+ let(:project_created_event) do
+ Projects::ProjectCreatedEvent.new(
+ data: {
+ project_id: project.id,
+ namespace_id: project.namespace_id,
+ root_namespace_id: project.root_namespace.id
+ })
+ end
+
+ it_behaves_like 'subscribes to event' do
+ let(:event) { project_created_event }
+ end
+
+ it 'creates an internal_ids sequence for ci_pipelines' do
+ consume_event(subscriber: described_class, event: project_created_event)
+
+ expect(project.internal_ids.ci_pipelines).to be_any
+ expect(project.internal_ids.ci_pipelines).to all be_persisted
+ end
+
+ context 'when the internal_ids sequence is already initialized' do
+ before do
+ create_list(:ci_pipeline, 2, project: project)
+ end
+
+ it 'does not reset the sequence' do
+ expect { consume_event(subscriber: described_class, event: project_created_event) }
+ .not_to change { project.internal_ids.ci_pipelines.pluck(:last_value) }
+ end
+ end
+end