Commit 314bbca3 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre Committed by Nick Thomas

Resolve "Geo: Prometheus metrics for checksummed/verification is confusing"

parent e1c8d698
...@@ -1094,6 +1094,12 @@ ActiveRecord::Schema.define(version: 20180425131009) do ...@@ -1094,6 +1094,12 @@ ActiveRecord::Schema.define(version: 20180425131009) do
t.integer "lfs_objects_synced_missing_on_primary_count" t.integer "lfs_objects_synced_missing_on_primary_count"
t.integer "job_artifacts_synced_missing_on_primary_count" t.integer "job_artifacts_synced_missing_on_primary_count"
t.integer "attachments_synced_missing_on_primary_count" t.integer "attachments_synced_missing_on_primary_count"
t.integer "repositories_checksummed_count"
t.integer "repositories_checksum_failed_count"
t.integer "repositories_checksum_mismatch_count"
t.integer "wikis_checksummed_count"
t.integer "wikis_checksum_failed_count"
t.integer "wikis_checksum_mismatch_count"
end end
add_index "geo_node_statuses", ["geo_node_id"], name: "index_geo_node_statuses_on_geo_node_id", unique: true, using: :btree add_index "geo_node_statuses", ["geo_node_id"], name: "index_geo_node_statuses_on_geo_node_id", unique: true, using: :btree
......
...@@ -76,6 +76,16 @@ the `monitoring.sidekiq_exporter` configuration option in `gitlab.yml`. ...@@ -76,6 +76,16 @@ the `monitoring.sidekiq_exporter` configuration option in `gitlab.yml`.
| geo_lfs_objects_synced_missing_on_primary | Gauge | 10.7 | Number of LFS objects marked as synced due to the file missing on the primary | url | geo_lfs_objects_synced_missing_on_primary | Gauge | 10.7 | Number of LFS objects marked as synced due to the file missing on the primary | url
| geo_job_artifacts_synced_missing_on_primary | Gauge | 10.7 | Number of job artifacts marked as synced due to the file missing on the primary | url | geo_job_artifacts_synced_missing_on_primary | Gauge | 10.7 | Number of job artifacts marked as synced due to the file missing on the primary | url
| geo_attachments_synced_missing_on_primary | Gauge | 10.7 | Number of attachments marked as synced due to the file missing on the primary | url | geo_attachments_synced_missing_on_primary | Gauge | 10.7 | Number of attachments marked as synced due to the file missing on the primary | url
| geo_repositories_checksummed_count | Gauge | 10.7 | Number of repositories checksummed on primary | url
| geo_repositories_checksum_failed_count | Gauge | 10.7 | Number of repositories failed to calculate the checksum on primary | url
| geo_wikis_checksummed_count | Gauge | 10.7 | Number of wikis checksummed on primary | url
| geo_wikis_checksum_failed_count | Gauge | 10.7 | Number of wikis failed to calculate the checksum on primary | url
| geo_repositories_verified_count | Gauge | 10.7 | Number of repositories verified on secondary | url
| geo_repositories_verification_failed_count | Gauge | 10.7 | Number of repositories failed to verify on secondary | url
| geo_repositories_checksum_mismatch_count | Gauge | 10.7 | Number of repositories that checksum mismatch on secondary | url
| geo_wikis_verified_count | Gauge | 10.7 | Number of wikis verified on secondary | url
| geo_wikis_verification_failed_count | Gauge | 10.7 | Number of wikis failed to verify on secondary | url
| geo_wikis_checksum_mismatch_count | Gauge | 10.7 | Number of wikis that checksum mismatch on secondary | url
## Metrics shared directory ## Metrics shared directory
......
...@@ -175,6 +175,20 @@ Example response: ...@@ -175,6 +175,20 @@ Example response:
"wikis_failed_count": 0, "wikis_failed_count": 0,
"wikis_synced_count": 41, "wikis_synced_count": 41,
"wikis_synced_in_percentage": "100.00%", "wikis_synced_in_percentage": "100.00%",
"repositories_checksummed_count": 20,
"repositories_checksum_failed_count": 5,
"repositories_checksummed_in_percentage": "48.78%",
"wikis_checksummed_count": 10,
"wikis_checksum_failed_count": 3,
"wikis_checksummed_in_percentage": "24.39%",
"repositories_verified_count": 20,
"repositories_verification_failed_count": 5,
"repositories_verified_in_percentage": "48.78%",
"repositories_checksum_mismatch_count": 3,
"wikis_verified_count": 10,
"wikis_verification_failed_count": 3,
"wikis_verified_in_percentage": "24.39%",
"wikis_checksum_mismatch_count": 1,
"last_event_id": 23, "last_event_id": 23,
"last_event_timestamp": 1509681166, "last_event_timestamp": 1509681166,
"cursor_last_event_id": 23, "cursor_last_event_id": 23,
......
...@@ -68,6 +68,14 @@ module Geo ...@@ -68,6 +68,14 @@ module Geo
relation.count relation.count
end end
def count_repositories_checksum_mismatch
Geo::ProjectRegistry.repository_checksum_mismatch.count
end
def count_wikis_checksum_mismatch
Geo::ProjectRegistry.wiki_checksum_mismatch.count
end
def count_verification_failed_repositories def count_verification_failed_repositories
find_verification_failed_project_registries('repository').count find_verification_failed_project_registries('repository').count
end end
......
...@@ -26,6 +26,8 @@ class Geo::ProjectRegistry < Geo::BaseRegistry ...@@ -26,6 +26,8 @@ class Geo::ProjectRegistry < Geo::BaseRegistry
scope :verified_wikis, -> { where.not(wiki_verification_checksum_sha: nil) } scope :verified_wikis, -> { where.not(wiki_verification_checksum_sha: nil) }
scope :verification_failed_repos, -> { where.not(last_repository_verification_failure: nil) } scope :verification_failed_repos, -> { where.not(last_repository_verification_failure: nil) }
scope :verification_failed_wikis, -> { where.not(last_wiki_verification_failure: nil) } scope :verification_failed_wikis, -> { where.not(last_wiki_verification_failure: nil) }
scope :repository_checksum_mismatch, -> { where(repository_checksum_mismatch: true) }
scope :wiki_checksum_mismatch, -> { where(wiki_checksum_mismatch: true) }
def self.failed def self.failed
repository_sync_failed = arel_table[:repository_retry_count].gt(0) repository_sync_failed = arel_table[:repository_retry_count].gt(0)
......
...@@ -29,10 +29,16 @@ class GeoNodeStatus < ActiveRecord::Base ...@@ -29,10 +29,16 @@ class GeoNodeStatus < ActiveRecord::Base
wikis_count: 'Total number of wikis available on primary', wikis_count: 'Total number of wikis available on primary',
wikis_synced_count: 'Number of wikis synced on secondary', wikis_synced_count: 'Number of wikis synced on secondary',
wikis_failed_count: 'Number of wikis failed to sync on secondary', wikis_failed_count: 'Number of wikis failed to sync on secondary',
repositories_checksummed_count: 'Number of repositories checksummed on primary',
repositories_checksum_failed_count: 'Number of repositories failed to calculate the checksum on primary',
wikis_checksummed_count: 'Number of wikis checksummed on primary',
wikis_checksum_failed_count: 'Number of wikis failed to calculate the checksum on primary',
repositories_verified_count: 'Number of repositories verified on secondary', repositories_verified_count: 'Number of repositories verified on secondary',
repositories_verification_failed_count: 'Number of repositories failed to verify on secondary', repositories_verification_failed_count: 'Number of repositories failed to verify on secondary',
repositories_checksum_mismatch_count: 'Number of repositories that checksum mismatch on secondary',
wikis_verified_count: 'Number of wikis verified on secondary', wikis_verified_count: 'Number of wikis verified on secondary',
wikis_verification_failed_count: 'Number of wikis failed to verify on secondary', wikis_verification_failed_count: 'Number of wikis failed to verify on secondary',
wikis_checksum_mismatch_count: 'Number of wikis that checksum mismatch on secondary',
lfs_objects_count: 'Total number of local LFS objects available on primary', lfs_objects_count: 'Total number of local LFS objects available on primary',
lfs_objects_synced_count: 'Number of local LFS objects synced on secondary', lfs_objects_synced_count: 'Number of local LFS objects synced on secondary',
lfs_objects_failed_count: 'Number of local LFS objects failed to sync on secondary', lfs_objects_failed_count: 'Number of local LFS objects failed to sync on secondary',
...@@ -168,7 +174,6 @@ class GeoNodeStatus < ActiveRecord::Base ...@@ -168,7 +174,6 @@ class GeoNodeStatus < ActiveRecord::Base
load_primary_data load_primary_data
load_secondary_data load_secondary_data
load_verification_data
self self
end end
...@@ -178,6 +183,13 @@ class GeoNodeStatus < ActiveRecord::Base ...@@ -178,6 +183,13 @@ class GeoNodeStatus < ActiveRecord::Base
self.replication_slots_count = geo_node.replication_slots_count self.replication_slots_count = geo_node.replication_slots_count
self.replication_slots_used_count = geo_node.replication_slots_used_count self.replication_slots_used_count = geo_node.replication_slots_used_count
self.replication_slots_max_retained_wal_bytes = geo_node.replication_slots_max_retained_wal_bytes self.replication_slots_max_retained_wal_bytes = geo_node.replication_slots_max_retained_wal_bytes
if repository_verification_enabled
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
end
end end
end end
...@@ -202,17 +214,20 @@ class GeoNodeStatus < ActiveRecord::Base ...@@ -202,17 +214,20 @@ class GeoNodeStatus < ActiveRecord::Base
self.attachments_failed_count = attachments_finder.count_failed_attachments self.attachments_failed_count = attachments_finder.count_failed_attachments
self.attachments_registry_count = attachments_finder.count_registry_attachments self.attachments_registry_count = attachments_finder.count_registry_attachments
self.attachments_synced_missing_on_primary_count = attachments_finder.count_synced_missing_on_primary_attachments self.attachments_synced_missing_on_primary_count = attachments_finder.count_synced_missing_on_primary_attachments
load_verification_data
end end
end end
def load_verification_data def load_verification_data
return unless repository_verification_enabled if repository_verification_enabled
self.repositories_verified_count = projects_finder.count_verified_repositories
finder = Gitlab::Geo.primary? ? repository_verification_finder : projects_finder self.repositories_verification_failed_count = projects_finder.count_verification_failed_repositories
self.repositories_verified_count = finder.count_verified_repositories self.repositories_checksum_mismatch_count = projects_finder.count_repositories_checksum_mismatch
self.repositories_verification_failed_count = finder.count_verification_failed_repositories self.wikis_verified_count = projects_finder.count_verified_wikis
self.wikis_verified_count = finder.count_verified_wikis self.wikis_verification_failed_count = projects_finder.count_verification_failed_wikis
self.wikis_verification_failed_count = finder.count_verification_failed_wikis self.wikis_checksum_mismatch_count = projects_finder.count_wikis_checksum_mismatch
end
end end
alias_attribute :health, :status_message alias_attribute :health, :status_message
...@@ -257,6 +272,14 @@ class GeoNodeStatus < ActiveRecord::Base ...@@ -257,6 +272,14 @@ class GeoNodeStatus < ActiveRecord::Base
calc_percentage(wikis_count, wikis_synced_count) calc_percentage(wikis_count, wikis_synced_count)
end end
def repositories_checksummed_in_percentage
calc_percentage(repositories_count, repositories_checksummed_count)
end
def wikis_checksummed_in_percentage
calc_percentage(wikis_count, wikis_checksummed_count)
end
def repositories_verified_in_percentage def repositories_verified_in_percentage
calc_percentage(repositories_count, repositories_verified_count) calc_percentage(repositories_count, repositories_verified_count)
end end
......
...@@ -166,6 +166,7 @@ module Geo ...@@ -166,6 +166,7 @@ module Geo
# Indicate that repository verification needs to be done again # Indicate that repository verification needs to be done again
attrs["#{type}_verification_checksum_sha"] = nil attrs["#{type}_verification_checksum_sha"] = nil
attrs["#{type}_checksum_mismatch"] = false
attrs["last_#{type}_verification_failure"] = nil attrs["last_#{type}_verification_failure"] = nil
end end
......
...@@ -43,7 +43,7 @@ module Geo ...@@ -43,7 +43,7 @@ module Geo
checksum = calculate_checksum checksum = calculate_checksum
if mismatch?(checksum) if mismatch?(checksum)
update_registry!(failure: "#{type.to_s.capitalize} checksum mismatch: #{repository.disk_path}") update_registry!(mismatch: true, failure: "#{type.to_s.capitalize} checksum mismatch: #{repository.disk_path}")
else else
update_registry!(checksum: checksum) update_registry!(checksum: checksum)
end end
...@@ -61,9 +61,10 @@ module Geo ...@@ -61,9 +61,10 @@ module Geo
primary_checksum != checksum primary_checksum != checksum
end end
def update_registry!(checksum: nil, failure: nil, exception: nil, details: {}) def update_registry!(checksum: nil, mismatch: false, failure: nil, exception: nil, details: {})
attrs = { attrs = {
"#{type}_verification_checksum_sha" => checksum, "#{type}_verification_checksum_sha" => checksum,
"#{type}_checksum_mismatch" => mismatch,
"last_#{type}_verification_failure" => failure "last_#{type}_verification_failure" => failure
} }
......
---
title: Geo - Improve metrics for the checksum/verification feature
merge_request: 5367
author:
type: changed
class AddChecksumMismatchFieldsToProjectRegistry < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
add_column :project_registry, :repository_checksum_mismatch, :boolean, null: false, default: false
add_column :project_registry, :wiki_checksum_mismatch, :boolean, null: false, default: false
end
end
class AddIndexesToChecksumMismatchFieldsOnProjectRegistry < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
REPOSITORY_INDEX_NAME = 'idx_repository_checksum_mismatch'
WIKI_INDEX_NAME = 'idx_wiki_checksum_mismatch'
disable_ddl_transaction!
def up
add_concurrent_index(
:project_registry,
:project_id,
name: REPOSITORY_INDEX_NAME,
where: 'repository_checksum_mismatch = true'
)
add_concurrent_index(
:project_registry,
:project_id,
name: WIKI_INDEX_NAME,
where: 'wiki_checksum_mismatch = true'
)
end
def down
remove_concurrent_index_by_name(:project_registry, REPOSITORY_INDEX_NAME)
remove_concurrent_index_by_name(:project_registry, WIKI_INDEX_NAME)
end
end
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20180412213305) do ActiveRecord::Schema.define(version: 20180419192603) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
...@@ -72,6 +72,8 @@ ActiveRecord::Schema.define(version: 20180412213305) do ...@@ -72,6 +72,8 @@ ActiveRecord::Schema.define(version: 20180412213305) do
t.string "last_wiki_verification_failure" t.string "last_wiki_verification_failure"
t.binary "repository_verification_checksum_sha" t.binary "repository_verification_checksum_sha"
t.binary "wiki_verification_checksum_sha" t.binary "wiki_verification_checksum_sha"
t.boolean "repository_checksum_mismatch", default: false, null: false
t.boolean "wiki_checksum_mismatch", default: false, null: false
end end
add_index "project_registry", ["last_repository_successful_sync_at"], name: "index_project_registry_on_last_repository_successful_sync_at", using: :btree add_index "project_registry", ["last_repository_successful_sync_at"], name: "index_project_registry_on_last_repository_successful_sync_at", using: :btree
...@@ -80,6 +82,8 @@ ActiveRecord::Schema.define(version: 20180412213305) do ...@@ -80,6 +82,8 @@ ActiveRecord::Schema.define(version: 20180412213305) do
add_index "project_registry", ["project_id"], name: "idx_project_registry_on_repository_failure_partial", where: "(last_repository_verification_failure IS NOT NULL)", using: :btree add_index "project_registry", ["project_id"], name: "idx_project_registry_on_repository_failure_partial", where: "(last_repository_verification_failure IS NOT NULL)", using: :btree
add_index "project_registry", ["project_id"], name: "idx_project_registry_on_wiki_checksums_and_failure_partial", where: "((wiki_verification_checksum_sha IS NULL) AND (last_wiki_verification_failure IS NULL))", using: :btree add_index "project_registry", ["project_id"], name: "idx_project_registry_on_wiki_checksums_and_failure_partial", where: "((wiki_verification_checksum_sha IS NULL) AND (last_wiki_verification_failure IS NULL))", using: :btree
add_index "project_registry", ["project_id"], name: "idx_project_registry_on_wiki_failure_partial", where: "(last_wiki_verification_failure IS NOT NULL)", using: :btree add_index "project_registry", ["project_id"], name: "idx_project_registry_on_wiki_failure_partial", where: "(last_wiki_verification_failure IS NOT NULL)", using: :btree
add_index "project_registry", ["project_id"], name: "idx_repository_checksum_mismatch", where: "(repository_checksum_mismatch = true)", using: :btree
add_index "project_registry", ["project_id"], name: "idx_wiki_checksum_mismatch", where: "(wiki_checksum_mismatch = true)", using: :btree
add_index "project_registry", ["project_id"], name: "index_project_registry_on_project_id", unique: true, using: :btree add_index "project_registry", ["project_id"], name: "index_project_registry_on_project_id", unique: true, using: :btree
add_index "project_registry", ["repository_retry_at"], name: "index_project_registry_on_repository_retry_at", using: :btree add_index "project_registry", ["repository_retry_at"], name: "index_project_registry_on_repository_retry_at", using: :btree
add_index "project_registry", ["repository_verification_checksum_sha"], name: "idx_project_registry_on_repository_checksum_sha_partial", where: "(repository_verification_checksum_sha IS NULL)", using: :btree add_index "project_registry", ["repository_verification_checksum_sha"], name: "idx_project_registry_on_repository_checksum_sha_partial", where: "(repository_verification_checksum_sha IS NULL)", using: :btree
......
class AddChecksumFieldsToGeoNodeStatuses < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
add_column :geo_node_statuses, :repositories_checksummed_count, :integer
add_column :geo_node_statuses, :repositories_checksum_failed_count, :integer
add_column :geo_node_statuses, :repositories_checksum_mismatch_count, :integer
add_column :geo_node_statuses, :wikis_checksummed_count, :integer
add_column :geo_node_statuses, :wikis_checksum_failed_count, :integer
add_column :geo_node_statuses, :wikis_checksum_mismatch_count, :integer
end
end
...@@ -299,17 +299,31 @@ module EE ...@@ -299,17 +299,31 @@ module EE
expose :repository_verification_enabled expose :repository_verification_enabled
expose :repositories_checksummed_count
expose :repositories_checksum_failed_count
expose :repositories_checksummed_in_percentage do |node|
number_to_percentage(node.repositories_checksummed_in_percentage, precision: 2)
end
expose :wikis_checksummed_count
expose :wikis_checksum_failed_count
expose :wikis_checksummed_in_percentage do |node|
number_to_percentage(node.wikis_checksummed_in_percentage, precision: 2)
end
expose :repositories_verification_failed_count expose :repositories_verification_failed_count
expose :repositories_verified_count expose :repositories_verified_count
expose :repositories_verified_in_percentage do |node| expose :repositories_verified_in_percentage do |node|
number_to_percentage(node.repositories_verified_in_percentage, precision: 2) number_to_percentage(node.repositories_verified_in_percentage, precision: 2)
end end
expose :repositories_checksum_mismatch_count
expose :wikis_verification_failed_count expose :wikis_verification_failed_count
expose :wikis_verified_count expose :wikis_verified_count
expose :wikis_verified_in_percentage do |node| expose :wikis_verified_in_percentage do |node|
number_to_percentage(node.wikis_verified_in_percentage, precision: 2) number_to_percentage(node.wikis_verified_in_percentage, precision: 2)
end end
expose :wikis_checksum_mismatch_count
expose :replication_slots_count expose :replication_slots_count
expose :replication_slots_used_count expose :replication_slots_used_count
......
...@@ -103,9 +103,13 @@ module Gitlab ...@@ -103,9 +103,13 @@ module Gitlab
end end
def handle_repository_updated_event(event, created_at) def handle_repository_updated_event(event, created_at)
registry = find_or_initialize_registry(event.project_id, registry = find_or_initialize_registry(
"resync_#{event.source}" => true, "#{event.source}_verification_checksum_sha" => nil, event.project_id,
"last_#{event.source}_verification_failure" => nil) "resync_#{event.source}" => true,
"#{event.source}_verification_checksum_sha" => nil,
"#{event.source}_checksum_mismatch" => false,
"last_#{event.source}_verification_failure" => nil
)
registry.save! registry.save!
......
...@@ -83,6 +83,11 @@ FactoryBot.define do ...@@ -83,6 +83,11 @@ FactoryBot.define do
last_repository_verification_failure 'Repository checksum did not match' last_repository_verification_failure 'Repository checksum did not match'
end end
trait :repository_checksum_mismatch do
last_repository_verification_failure 'Repository checksum mismatch'
repository_checksum_mismatch true
end
trait :repository_verification_outdated do trait :repository_verification_outdated do
repository_verification_checksum_sha nil repository_verification_checksum_sha nil
last_repository_verification_failure nil last_repository_verification_failure nil
...@@ -98,6 +103,11 @@ FactoryBot.define do ...@@ -98,6 +103,11 @@ FactoryBot.define do
last_wiki_verification_failure 'Wiki checksum did not match' last_wiki_verification_failure 'Wiki checksum did not match'
end end
trait :wiki_checksum_mismatch do
last_wiki_verification_failure 'Wiki checksum mismatch'
wiki_checksum_mismatch true
end
trait :wiki_verification_outdated do trait :wiki_verification_outdated do
wiki_verification_checksum_sha nil wiki_verification_checksum_sha nil
last_wiki_verification_failure nil last_wiki_verification_failure nil
......
...@@ -23,10 +23,16 @@ FactoryBot.define do ...@@ -23,10 +23,16 @@ FactoryBot.define do
wikis_count 9 wikis_count 9
wikis_synced_count 4 wikis_synced_count 4
wikis_failed_count 1 wikis_failed_count 1
repositories_checksummed_count 600
repositories_checksum_failed_count 120
wikis_checksummed_count 585
wikis_checksum_failed_count 55
repositories_verified_count 501 repositories_verified_count 501
repositories_verification_failed_count 100 repositories_verification_failed_count 100
repositories_checksum_mismatch_count 15
wikis_verified_count 499 wikis_verified_count 499
wikis_verification_failed_count 99 wikis_verification_failed_count 99
wikis_checksum_mismatch_count 10
last_event_id 2 last_event_id 2
last_event_timestamp { Time.now.to_i } last_event_timestamp { Time.now.to_i }
cursor_last_event_id 1 cursor_last_event_id 1
......
...@@ -26,12 +26,20 @@ ...@@ -26,12 +26,20 @@
"wikis_failed_count", "wikis_failed_count",
"wikis_synced_count", "wikis_synced_count",
"repository_verification_enabled", "repository_verification_enabled",
"repositories_checksummed_count",
"repositories_checksum_failed_count",
"repositories_checksummed_in_percentage",
"wikis_checksummed_count",
"wikis_checksum_failed_count",
"wikis_checksummed_in_percentage",
"repositories_verified_count", "repositories_verified_count",
"repositories_verification_failed_count", "repositories_verification_failed_count",
"repositories_verified_in_percentage", "repositories_verified_in_percentage",
"repositories_checksum_mismatch_count",
"wikis_verified_count", "wikis_verified_count",
"wikis_verification_failed_count", "wikis_verification_failed_count",
"wikis_verified_in_percentage", "wikis_verified_in_percentage",
"wikis_checksum_mismatch_count",
"replication_slots_count", "replication_slots_count",
"replication_slots_used_count", "replication_slots_used_count",
"replication_slots_used_in_percentage", "replication_slots_used_in_percentage",
...@@ -71,19 +79,27 @@ ...@@ -71,19 +79,27 @@
"job_artifacts_synced_in_percentage": { "type": "string" }, "job_artifacts_synced_in_percentage": { "type": "string" },
"repositories_count": { "type": "integer" }, "repositories_count": { "type": "integer" },
"repositories_failed_count": { "type": ["integer", "null"] }, "repositories_failed_count": { "type": ["integer", "null"] },
"repository_verification_enabled": { "type": "boolean" },
"repositories_synced_count": { "type": ["integer", "null"] }, "repositories_synced_count": { "type": ["integer", "null"] },
"repositories_synced_in_percentage": { "type": "string" }, "repositories_synced_in_percentage": { "type": "string" },
"wikis_count": { "type": "integer" }, "wikis_count": { "type": "integer" },
"wikis_failed_count": { "type": ["integer", "null"] }, "wikis_failed_count": { "type": ["integer", "null"] },
"wikis_synced_count": { "type": ["integer", "null"] }, "wikis_synced_count": { "type": ["integer", "null"] },
"wikis_synced_in_percentage": { "type": "string" }, "wikis_synced_in_percentage": { "type": "string" },
"repository_verification_enabled": { "type": "boolean" }, "repositories_checksummed_count": { "type": ["integer", "null"] },
"repositories_checksum_failed_count": { "type": ["integer", "null"] },
"repositories_checksummed_in_percentage": { "type": "string" },
"wikis_checksummed_count": { "type": ["integer", "null"] },
"wikis_checksum_failed_count": { "type": ["integer", "null"] },
"wikis_checksummed_in_percentage": { "type": "string" },
"repositories_verified_count": { "type": ["integer", "null"] }, "repositories_verified_count": { "type": ["integer", "null"] },
"repositories_verification_failed_count": { "type": ["integer", "null"] }, "repositories_verification_failed_count": { "type": ["integer", "null"] },
"repositories_verified_in_percentage": { "type": "string" }, "repositories_verified_in_percentage": { "type": "string" },
"repositories_checksum_mismatch_count": { "type": ["integer", "null"] },
"wikis_verified_count": { "type": ["integer", "null"] }, "wikis_verified_count": { "type": ["integer", "null"] },
"wikis_verification_failed_count": { "type": ["integer", "null"] }, "wikis_verification_failed_count": { "type": ["integer", "null"] },
"wikis_verified_in_percentage": { "type": "string" }, "wikis_verified_in_percentage": { "type": "string" },
"wikis_checksum_mismatch_count": { "type": ["integer", "null"] },
"replication_slots_count": { "type": ["integer", "null"] }, "replication_slots_count": { "type": ["integer", "null"] },
"replication_slots_used_count": { "type": ["integer", "null"] }, "replication_slots_used_count": { "type": ["integer", "null"] },
"replication_slots_used_in_percentage": { "type": "string" }, "replication_slots_used_in_percentage": { "type": "string" },
......
...@@ -113,7 +113,7 @@ describe Gitlab::Geo::LogCursor::Daemon, :postgresql, :clean_gitlab_redis_shared ...@@ -113,7 +113,7 @@ describe Gitlab::Geo::LogCursor::Daemon, :postgresql, :clean_gitlab_redis_shared
end end
context 'when event source is repository' do context 'when event source is repository' do
let!(:registry) { create(:geo_project_registry, :synced, :repository_verified, project: repository_updated_event.project) } let!(:registry) { create(:geo_project_registry, :synced, :repository_verified, :repository_checksum_mismatch, project: repository_updated_event.project) }
before do before do
repository_updated_event.update!(source: Geo::RepositoryUpdatedEvent::REPOSITORY) repository_updated_event.update!(source: Geo::RepositoryUpdatedEvent::REPOSITORY)
...@@ -125,16 +125,19 @@ describe Gitlab::Geo::LogCursor::Daemon, :postgresql, :clean_gitlab_redis_shared ...@@ -125,16 +125,19 @@ describe Gitlab::Geo::LogCursor::Daemon, :postgresql, :clean_gitlab_redis_shared
expect(registry.reload.resync_repository).to be true expect(registry.reload.resync_repository).to be true
end end
it 'resets the repository verification checksum and failure' do it 'resets the repository verification fields' do
daemon.run_once! daemon.run_once!
expect(registry.reload).to have_attributes( expect(registry.reload).to have_attributes(
resync_repository: true, repository_verification_checksum_sha: nil, last_repository_verification_failure: nil) repository_verification_checksum_sha: nil,
repository_checksum_mismatch: false,
last_repository_verification_failure: nil
)
end end
end end
context 'when event source is wiki' do context 'when event source is wiki' do
let!(:registry) { create(:geo_project_registry, :synced, :wiki_verified, project: repository_updated_event.project) } let!(:registry) { create(:geo_project_registry, :synced, :wiki_verified, :wiki_checksum_mismatch, project: repository_updated_event.project) }
before do before do
repository_updated_event.update!(source: Geo::RepositoryUpdatedEvent::WIKI) repository_updated_event.update!(source: Geo::RepositoryUpdatedEvent::WIKI)
...@@ -146,11 +149,14 @@ describe Gitlab::Geo::LogCursor::Daemon, :postgresql, :clean_gitlab_redis_shared ...@@ -146,11 +149,14 @@ describe Gitlab::Geo::LogCursor::Daemon, :postgresql, :clean_gitlab_redis_shared
expect(registry.reload.resync_wiki).to be true expect(registry.reload.resync_wiki).to be true
end end
it 'resets the wiki verification checksum and failure' do it 'resets the wiki repository verification fields' do
daemon.run_once! daemon.run_once!
expect(registry.reload).to have_attributes( expect(registry.reload).to have_attributes(
resync_wiki: true, wiki_verification_checksum_sha: nil, last_wiki_verification_failure: nil) wiki_verification_checksum_sha: nil,
wiki_checksum_mismatch: false,
last_wiki_verification_failure: nil
)
end end
end end
......
This diff is collapsed.
...@@ -171,6 +171,12 @@ describe Geo::RepositorySyncService do ...@@ -171,6 +171,12 @@ describe Geo::RepositorySyncService do
expect(registry.last_repository_verification_failure).to be_nil expect(registry.last_repository_verification_failure).to be_nil
end end
it 'resets the repository_checksum_mismatch' do
subject.execute
expect(registry.repository_checksum_mismatch).to eq false
end
it 'logs success with timings' do it 'logs success with timings' do
allow(Gitlab::Geo::Logger).to receive(:info).and_call_original allow(Gitlab::Geo::Logger).to receive(:info).and_call_original
expect(Gitlab::Geo::Logger).to receive(:info).with(hash_including(:message, :update_delay_s, :download_time_s)).and_call_original expect(Gitlab::Geo::Logger).to receive(:info).with(hash_including(:message, :update_delay_s, :download_time_s)).and_call_original
......
...@@ -50,8 +50,13 @@ describe Geo::RepositoryVerifySecondaryService, :geo do ...@@ -50,8 +50,13 @@ describe Geo::RepositoryVerifySecondaryService, :geo do
it 'sets checksum when the checksum matches' do it 'sets checksum when the checksum matches' do
expect(repository).to receive(:checksum).and_return('my_checksum') expect(repository).to receive(:checksum).and_return('my_checksum')
expect { service.execute }.to change(registry, "#{type}_verification_checksum_sha") service.execute
.from(nil).to('my_checksum')
expect(registry).to have_attributes(
"#{type}_verification_checksum_sha" => 'my_checksum',
"#{type}_checksum_mismatch" => false,
"last_#{type}_verification_failure" => nil
)
end end
it 'does not mark the verification as failed when there is no repo' do it 'does not mark the verification as failed when there is no repo' do
...@@ -61,8 +66,9 @@ describe Geo::RepositoryVerifySecondaryService, :geo do ...@@ -61,8 +66,9 @@ describe Geo::RepositoryVerifySecondaryService, :geo do
service.execute service.execute
expect(registry.reload).to have_attributes( expect(registry).to have_attributes(
"#{type}_verification_checksum_sha" => '0000000000000000000000000000000000000000', "#{type}_verification_checksum_sha" => '0000000000000000000000000000000000000000',
"#{type}_checksum_mismatch" => false,
"last_#{type}_verification_failure" => nil "last_#{type}_verification_failure" => nil
) )
end end
...@@ -70,8 +76,13 @@ describe Geo::RepositoryVerifySecondaryService, :geo do ...@@ -70,8 +76,13 @@ describe Geo::RepositoryVerifySecondaryService, :geo do
it 'keeps track of failure when the checksum mismatch' do it 'keeps track of failure when the checksum mismatch' do
expect(repository).to receive(:checksum).and_return('other_checksum') expect(repository).to receive(:checksum).and_return('other_checksum')
expect { service.execute }.to change(registry, "last_#{type}_verification_failure") service.execute
.from(nil).to(/#{Regexp.quote(type.to_s.capitalize)} checksum mismatch/)
expect(registry).to have_attributes(
"#{type}_verification_checksum_sha" => nil,
"#{type}_checksum_mismatch" => true,
"last_#{type}_verification_failure" => /#{Regexp.quote(type.to_s.capitalize)} checksum mismatch/
)
end end
def find_repository(type) def find_repository(type)
......
...@@ -150,6 +150,12 @@ RSpec.describe Geo::WikiSyncService do ...@@ -150,6 +150,12 @@ RSpec.describe Geo::WikiSyncService do
expect(registry.last_wiki_verification_failure).to be_nil expect(registry.last_wiki_verification_failure).to be_nil
end end
it 'resets the wiki_checksum_mismatch' do
subject.execute
expect(registry.wiki_checksum_mismatch).to eq false
end
it 'logs success with timings' do it 'logs success with timings' do
allow(Gitlab::Geo::Logger).to receive(:info).and_call_original allow(Gitlab::Geo::Logger).to receive(:info).and_call_original
expect(Gitlab::Geo::Logger).to receive(:info).with(hash_including(:message, :update_delay_s, :download_time_s)).and_call_original expect(Gitlab::Geo::Logger).to receive(:info).with(hash_including(:message, :update_delay_s, :download_time_s)).and_call_original
......
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