Commit 35204cc1 authored by Michael Kozono's avatar Michael Kozono

Merge branch '225519-geo-add-package-files-to-status-rake-tasks' into 'master'

Geo: Add package files to status rake tasks

Closes #225519

See merge request gitlab-org/gitlab!36192
parents a9a3dec1 a5450bfe
......@@ -378,6 +378,14 @@ class GeoNodeStatus < ApplicationRecord
attr_in_percentage :package_files_checksummed, :package_files_checksummed_count, :package_files_count
attr_in_percentage :package_files_synced, :package_files_synced_count, :package_files_registry_count
def synced_in_percentage_for(replicator_class)
public_send("#{replicator_class.replicable_name_plural}_synced_in_percentage") # rubocop:disable GitlabSecurity/PublicSend
end
def checksummed_in_percentage_for(replicator_class)
public_send("#{replicator_class.replicable_name_plural}_checksummed_in_percentage") # rubocop:disable GitlabSecurity/PublicSend
end
def storage_shards_match?
return true if geo_node.primary?
return false unless storage_configuration_digest && primary_storage_digest
......
---
title: 'Geo: Add package files to status rake tasks'
merge_request: 36192
author:
type: changed
......@@ -33,7 +33,9 @@ module Gitlab
print_ci_job_artifacts_status
print_container_repositories_status
print_design_repositories_status
print_replicators_status
print_repositories_checked_status
print_replicators_checked_status
print_sync_settings
print_db_replication_lag
......@@ -53,7 +55,9 @@ module Gitlab
print_ci_job_artifacts_status
print_container_repositories_status
print_design_repositories_status
print_replicators_status
print_repositories_checked_status
print_replicators_checked_status
end
def replication_verification_complete?
......@@ -159,6 +163,17 @@ module Gitlab
puts using_percentage(current_node_status.repositories_synced_in_percentage)
end
def print_replicators_status
Gitlab::Geo.replicator_classes.each do |replicator_class|
print "#{replicator_class.replicable_title_plural}: ".rjust(GEO_STATUS_COLUMN_WIDTH)
show_failed_value(replicator_class.failed_count)
print "#{replicator_class.synced_count}/#{replicator_class.registry_count} "
puts using_percentage(current_node_status.synced_in_percentage_for(replicator_class))
end
end
def print_verified_repositories
if Gitlab::Geo.repository_verification_enabled?
print 'Verified Repositories: '.rjust(GEO_STATUS_COLUMN_WIDTH)
......@@ -230,6 +245,15 @@ module Gitlab
end
end
def print_replicators_checked_status
Gitlab::Geo.replicator_classes.each do |replicator_class|
print "#{replicator_class.replicable_title_plural} Checked: ".rjust(GEO_STATUS_COLUMN_WIDTH)
show_failed_value(replicator_class.checksum_failed_count)
print "#{replicator_class.checksummed_count}/#{replicator_class.registry_count} "
puts using_percentage(current_node_status.checksummed_in_percentage_for(replicator_class))
end
end
def replication_complete?
replicables.all? { |failed_count| failed_count == 0 }
end
......@@ -250,6 +274,10 @@ module Gitlab
if Gitlab.config.geo.registry_replication.enabled
r.push current_node_status.container_repositories_failed_count
end
Gitlab::Geo.replicator_classes.each do |replicator_class|
r.push replicator_class.failed_count
end
end
end
......@@ -265,6 +293,10 @@ module Gitlab
if Gitlab::CurrentSettings.repository_checks_enabled
v.push current_node_status.repositories_checked_failed_count
end
Gitlab::Geo.replicator_classes.each do |replicator_class|
v.push replicator_class.checksum_failed_count
end
end
end
......
......@@ -26,7 +26,8 @@ RSpec.describe Gitlab::Geo::GeoNodeStatusCheck do
/CI job artifacts/,
/Container repositories/,
/Design repositories/,
/Repositories Checked/
/Repositories Checked/,
/Package Files Checked/
].each do |text|
expect { subject.print_replication_verification_status }.to output(text).to_stdout
end
......@@ -39,11 +40,15 @@ RSpec.describe Gitlab::Geo::GeoNodeStatusCheck do
end
context 'when replication is not up-to-date' do
before do
it 'returns false when repositories_checked_failed_count is positive' do
allow(geo_node_status).to receive(:repositories_checked_failed_count).and_return(1)
expect(subject.replication_verification_complete?).to be_falsy
end
it 'returns false' do
it 'returns false when there are package files failed to sync' do
allow(::Geo::PackageFileReplicator).to receive(:failed_count).and_return(1)
expect(subject.replication_verification_complete?).to be_falsy
end
end
......
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