Fix Geo node status when treating registry SSOT for projects

We should use the registry table as the SSOT while
calculating the Geo node status when the registry
consistency worker is enabled for projects and
wikis.
parent fc115968
......@@ -431,11 +431,8 @@ class GeoNodeStatus < ApplicationRecord
self.db_replication_lag_seconds = Gitlab::Geo::HealthCheck.new.db_replication_lag_seconds
self.cursor_last_event_id = current_cursor_last_event_id
self.cursor_last_event_date = Geo::EventLog.find_by(id: self.cursor_last_event_id)&.created_at
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
load_repositories_data
load_lfs_objects_data
load_job_artifacts_data
load_attachments_data
......@@ -444,6 +441,20 @@ class GeoNodeStatus < ApplicationRecord
load_package_files_data
end
def load_repositories_data
if Geo::ProjectRegistry.registry_consistency_worker_enabled?
self.repositories_synced_count = Geo::ProjectRegistry.synced(:repository).count
self.repositories_failed_count = Geo::ProjectRegistry.sync_failed(:repository).count
self.wikis_synced_count = Geo::ProjectRegistry.synced(: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
def load_lfs_objects_data
return unless lfs_objects_replication_enabled
......@@ -514,13 +525,32 @@ class GeoNodeStatus < ApplicationRecord
return unless repository_verification_enabled
if Gitlab::Geo.primary?
load_primary_verification_data
elsif Gitlab::Geo.secondary?
load_secondary_verification_data
end
end
def load_primary_verification_data
self.repositories_checksummed_count = repository_verification_finder.count_verified_repositories
self.repositories_checksum_failed_count = repository_verification_finder.count_verification_failed_repositories
self.wikis_checksummed_count = repository_verification_finder.count_verified_wikis
self.wikis_checksum_failed_count = repository_verification_finder.count_verification_failed_wikis
self.package_files_checksummed_count = Geo::PackageFileReplicator.checksummed_count
self.package_files_checksum_failed_count = Geo::PackageFileReplicator.checksum_failed_count
elsif Gitlab::Geo.secondary?
end
def load_secondary_verification_data
if Geo::ProjectRegistry.registry_consistency_worker_enabled?
self.repositories_verified_count = Geo::ProjectRegistry.verified(:repository).count
self.repositories_verification_failed_count = Geo::ProjectRegistry.verification_failed(:repository).count
self.repositories_checksum_mismatch_count = Geo::ProjectRegistry.mismatch(:repository).count
self.wikis_verified_count = Geo::ProjectRegistry.verified(:wiki).count
self.wikis_verification_failed_count = Geo::ProjectRegistry.verification_failed(:wiki).count
self.wikis_checksum_mismatch_count = Geo::ProjectRegistry.mismatch(:wiki).count
self.repositories_retrying_verification_count = Geo::ProjectRegistry.retrying_verification(:repository).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
......
This diff is collapsed.
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