Commit 43afb39a authored by Michael Kozono's avatar Michael Kozono

Merge branch...

Merge branch '223249-remove-feature-flag-to-make-registry-table-ssot-for-projects-and-wikis' into 'master'

Remove feature flag to make registry table SSOT for Projects and Wikis

See merge request gitlab-org/gitlab!37843
parents dddad006 020eed32
...@@ -43,10 +43,6 @@ class Geo::ProjectRegistry < Geo::BaseRegistry ...@@ -43,10 +43,6 @@ class Geo::ProjectRegistry < Geo::BaseRegistry
where(nil).pluck(:project_id) where(nil).pluck(:project_id)
end end
def self.registry_consistency_worker_enabled?
Feature.enabled?(:geo_project_registry_ssot_sync, default_enabled: true)
end
def self.find_registry_differences(range) def self.find_registry_differences(range)
source_ids = Gitlab::Geo.current_node.projects.id_in(range).pluck_primary_key source_ids = Gitlab::Geo.current_node.projects.id_in(range).pluck_primary_key
tracked_ids = self.pluck_model_ids_in_range(range) tracked_ids = self.pluck_model_ids_in_range(range)
......
...@@ -450,17 +450,10 @@ class GeoNodeStatus < ApplicationRecord ...@@ -450,17 +450,10 @@ class GeoNodeStatus < ApplicationRecord
end end
def load_repositories_data def load_repositories_data
if Geo::ProjectRegistry.registry_consistency_worker_enabled? self.repositories_synced_count = Geo::ProjectRegistry.synced(:repository).count
self.repositories_synced_count = Geo::ProjectRegistry.synced(:repository).count self.repositories_failed_count = Geo::ProjectRegistry.sync_failed(:repository).count
self.repositories_failed_count = Geo::ProjectRegistry.sync_failed(:repository).count self.wikis_synced_count = Geo::ProjectRegistry.synced(:wiki).count
self.wikis_synced_count = Geo::ProjectRegistry.synced(:wiki).count self.wikis_failed_count = Geo::ProjectRegistry.sync_failed(:wiki).count
self.wikis_failed_count = Geo::ProjectRegistry.sync_failed(:wiki).count
else
self.repositories_synced_count = registries_for_synced_projects(:repository).count
self.repositories_failed_count = registries_for_failed_projects(:repository).count
self.wikis_synced_count = registries_for_synced_projects(:wiki).count
self.wikis_failed_count = registries_for_failed_projects(:wiki).count
end
end end
def load_lfs_objects_data def load_lfs_objects_data
...@@ -549,25 +542,14 @@ class GeoNodeStatus < ApplicationRecord ...@@ -549,25 +542,14 @@ class GeoNodeStatus < ApplicationRecord
end end
def load_secondary_verification_data def load_secondary_verification_data
if Geo::ProjectRegistry.registry_consistency_worker_enabled? self.repositories_verified_count = Geo::ProjectRegistry.verified(:repository).count
self.repositories_verified_count = Geo::ProjectRegistry.verified(:repository).count self.repositories_verification_failed_count = Geo::ProjectRegistry.verification_failed(:repository).count
self.repositories_verification_failed_count = Geo::ProjectRegistry.verification_failed(:repository).count self.repositories_checksum_mismatch_count = Geo::ProjectRegistry.mismatch(:repository).count
self.repositories_checksum_mismatch_count = Geo::ProjectRegistry.mismatch(:repository).count self.wikis_verified_count = Geo::ProjectRegistry.verified(:wiki).count
self.wikis_verified_count = Geo::ProjectRegistry.verified(:wiki).count self.wikis_verification_failed_count = Geo::ProjectRegistry.verification_failed(:wiki).count
self.wikis_verification_failed_count = Geo::ProjectRegistry.verification_failed(:wiki).count self.wikis_checksum_mismatch_count = Geo::ProjectRegistry.mismatch(:wiki).count
self.wikis_checksum_mismatch_count = Geo::ProjectRegistry.mismatch(:wiki).count self.repositories_retrying_verification_count = Geo::ProjectRegistry.retrying_verification(:repository).count
self.repositories_retrying_verification_count = Geo::ProjectRegistry.retrying_verification(:repository).count self.wikis_retrying_verification_count = Geo::ProjectRegistry.retrying_verification(:wiki).count
self.wikis_retrying_verification_count = Geo::ProjectRegistry.retrying_verification(:wiki).count
else
self.repositories_verified_count = registries_for_verified_projects(:repository).count
self.repositories_verification_failed_count = registries_for_verification_failed_projects(:repository).count
self.repositories_checksum_mismatch_count = registries_for_mismatch_projects(:repository).count
self.wikis_verified_count = registries_for_verified_projects(:wiki).count
self.wikis_verification_failed_count = registries_for_verification_failed_projects(:wiki).count
self.wikis_checksum_mismatch_count = registries_for_mismatch_projects(:wiki).count
self.repositories_retrying_verification_count = registries_retrying_verification(:repository).count
self.wikis_retrying_verification_count = registries_retrying_verification(:wiki).count
end
end end
def primary_storage_digest def primary_storage_digest
...@@ -594,42 +576,6 @@ class GeoNodeStatus < ApplicationRecord ...@@ -594,42 +576,6 @@ class GeoNodeStatus < ApplicationRecord
@design_registry_finder ||= Geo::DesignRegistryFinder.new(current_node_id: geo_node.id) @design_registry_finder ||= Geo::DesignRegistryFinder.new(current_node_id: geo_node.id)
end end
def registries_for_synced_projects(type)
Geo::ProjectRegistrySyncedFinder
.new(current_node: geo_node, type: type)
.execute
end
def registries_for_failed_projects(type)
Geo::ProjectRegistrySyncFailedFinder
.new(current_node: geo_node, type: type)
.execute
end
def registries_for_verified_projects(type)
Geo::ProjectRegistryVerifiedFinder
.new(current_node: geo_node, type: type)
.execute
end
def registries_for_verification_failed_projects(type)
Geo::ProjectRegistryVerificationFailedFinder
.new(current_node: geo_node, type: type)
.execute
end
def registries_for_mismatch_projects(type)
Geo::ProjectRegistryMismatchFinder
.new(current_node: geo_node, type: type)
.execute
end
def registries_retrying_verification(type)
Geo::ProjectRegistryRetryingVerificationFinder
.new(current_node: geo_node, type: type)
.execute
end
def repository_verification_finder def repository_verification_finder
@repository_verification_finder ||= Geo::RepositoryVerificationFinder.new @repository_verification_finder ||= Geo::RepositoryVerificationFinder.new
end end
......
...@@ -76,66 +76,32 @@ module Geo ...@@ -76,66 +76,32 @@ module Geo
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def find_project_ids_not_synced(except_ids:, batch_size:) def find_project_ids_not_synced(except_ids:, batch_size:)
if Geo::ProjectRegistry.registry_consistency_worker_enabled? project_ids =
project_ids = registry_finder
find_never_synced_project_ids(batch_size: batch_size, except_ids: except_ids) .find_never_synced_registries(batch_size: batch_size, except_ids: except_ids)
.pluck_model_foreign_key
find_project_ids_within_shard(project_ids, direction: :desc) find_project_ids_within_shard(project_ids, direction: :desc)
else
find_unsynced_projects(batch_size: batch_size)
.id_not_in(except_ids)
.reorder(last_repository_updated_at: :desc)
.pluck_primary_key
end
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
def find_unsynced_projects(batch_size:)
Geo::ProjectUnsyncedFinder
.new(current_node: current_node, shard_name: shard_name, batch_size: batch_size)
.execute
end
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def find_project_ids_updated_recently(except_ids:, batch_size:) def find_project_ids_updated_recently(except_ids:, batch_size:)
if Geo::ProjectRegistry.registry_consistency_worker_enabled? project_ids =
project_ids = registry_finder
find_retryable_dirty_project_ids(batch_size: batch_size, except_ids: except_ids) .find_retryable_dirty_registries(batch_size: batch_size, except_ids: except_ids)
.pluck_model_foreign_key
find_project_ids_within_shard(project_ids, direction: :asc) find_project_ids_within_shard(project_ids, direction: :asc)
else
find_projects_updated_recently(batch_size: batch_size)
.id_not_in(except_ids)
.order('project_registry.last_repository_synced_at ASC NULLS FIRST, projects.last_repository_updated_at ASC')
.pluck_primary_key
end
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
def find_projects_updated_recently(batch_size:)
Geo::ProjectUpdatedRecentlyFinder
.new(current_node: current_node, shard_name: shard_name, batch_size: batch_size)
.execute
end
def valid_shard? def valid_shard?
return true unless current_node.selective_sync_by_shards? return true unless current_node.selective_sync_by_shards?
current_node.selective_sync_shards.include?(shard_name) current_node.selective_sync_shards.include?(shard_name)
end end
def find_never_synced_project_ids(batch_size:, except_ids:)
registry_finder
.find_never_synced_registries(batch_size: batch_size, except_ids: except_ids)
.pluck_model_foreign_key
end
def find_retryable_dirty_project_ids(batch_size:, except_ids:)
registry_finder
.find_retryable_dirty_registries(batch_size: batch_size, except_ids: except_ids)
.pluck_model_foreign_key
end
# rubocop:disable CodeReuse/ActiveRecord # rubocop:disable CodeReuse/ActiveRecord
def find_project_ids_within_shard(project_ids, direction:) def find_project_ids_within_shard(project_ids, direction:)
Project Project
......
...@@ -43,22 +43,14 @@ module Geo ...@@ -43,22 +43,14 @@ module Geo
def load_pending_resources def load_pending_resources
return [] unless valid_shard? return [] unless valid_shard?
if Geo::ProjectRegistry.registry_consistency_worker_enabled? project_ids =
project_ids = registry_finder
registry_finder .find_project_ids_pending_verification(batch_size: db_retrieve_batch_size, except_ids: scheduled_project_ids)
.find_project_ids_pending_verification(batch_size: db_retrieve_batch_size, except_ids: scheduled_project_ids)
Project
Project .id_in(project_ids)
.id_in(project_ids) .within_shards(shard_name)
.within_shards(shard_name) .pluck_primary_key
.pluck_primary_key
else
Geo::ProjectRegistryPendingVerificationFinder
.new(current_node: current_node, shard_name: shard_name, batch_size: db_retrieve_batch_size)
.execute
.merge(Geo::ProjectRegistry.model_id_not_in(scheduled_project_ids))
.pluck(Geo::Fdw::Project.arel_table[:id])
end
end end
# rubocop:enable CodeReuse/ActiveRecord # rubocop:enable CodeReuse/ActiveRecord
......
This diff is collapsed.
...@@ -101,28 +101,6 @@ RSpec.describe Geo::Secondary::RegistryConsistencyWorker, :geo, :geo_fdw do ...@@ -101,28 +101,6 @@ RSpec.describe Geo::Secondary::RegistryConsistencyWorker, :geo, :geo_fdw do
expect(Geo::PackageFileRegistry.where(package_file_id: package_file.id).count).to eq(1) expect(Geo::PackageFileRegistry.where(package_file_id: package_file.id).count).to eq(1)
end end
context 'when geo_project_registry_ssot_sync is disabled' do
before do
stub_feature_flags(geo_project_registry_ssot_sync: false)
end
it 'returns false' do
expect(subject.perform).to be_falsey
end
it 'does not execute RegistryConsistencyService for projects' do
allow(Geo::RegistryConsistencyService).to receive(:new).with(Geo::JobArtifactRegistry, batch_size: batch_size).and_call_original
allow(Geo::RegistryConsistencyService).to receive(:new).with(Geo::LfsObjectRegistry, batch_size: batch_size).and_call_original
allow(Geo::RegistryConsistencyService).to receive(:new).with(Geo::PackageFileRegistry, batch_size: batch_size).and_call_original
allow(Geo::RegistryConsistencyService).to receive(:new).with(Geo::UploadRegistry, batch_size: batch_size).and_call_original
allow(Geo::RegistryConsistencyService).to receive(:new).with(Geo::DesignRegistry, batch_size: batch_size).and_call_original
expect(Geo::RegistryConsistencyService).not_to receive(:new).with(Geo::ProjectRegistry, batch_size: batch_size)
subject.perform
end
end
context 'when geo_design_registry_ssot_sync is disabled' do context 'when geo_design_registry_ssot_sync is disabled' do
before do before do
stub_feature_flags(geo_design_registry_ssot_sync: false) stub_feature_flags(geo_design_registry_ssot_sync: false)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment