Commit 4e942edc authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre Committed by Nick Thomas

Geo - Store the invalid checksum when we have a mismatch

parent 8573bbb6
......@@ -17,7 +17,9 @@ class Geo::ProjectRegistry < Geo::BaseRegistry
ignore_column :wiki_verification_checksum
sha_attribute :repository_verification_checksum_sha
sha_attribute :repository_verification_checksum_mismatched
sha_attribute :wiki_verification_checksum_sha
sha_attribute :wiki_verification_checksum_mismatched
belongs_to :project
......
......@@ -48,7 +48,7 @@ module Geo
checksum = calculate_checksum(repository)
if mismatch?(checksum)
update_registry!(mismatch: true, failure: "#{type.to_s.capitalize} checksum mismatch")
update_registry!(mismatch: checksum, failure: "#{type.to_s.capitalize} checksum mismatch")
else
update_registry!(checksum: checksum)
end
......@@ -56,7 +56,7 @@ module Geo
update_registry!(failure: "Error calculating #{type} checksum", exception: e)
end
def update_registry!(checksum: nil, mismatch: false, failure: nil, exception: nil)
def update_registry!(checksum: nil, mismatch: nil, failure: nil, exception: nil)
reverify, verification_retry_count =
if mismatch || failure.present?
log_error(failure, exception, type: type)
......@@ -72,7 +72,8 @@ module Geo
registry.update!(
"#{type}_verification_checksum_sha" => checksum,
"#{type}_checksum_mismatch" => mismatch,
"#{type}_verification_checksum_mismatched" => mismatch,
"#{type}_checksum_mismatch" => mismatch.present?,
"last_#{type}_verification_ran_at" => Time.now,
"last_#{type}_verification_failure" => failure,
"#{type}_verification_retry_count" => verification_retry_count,
......
---
title: Geo - Store the invalid checksum when we have a mismatch
merge_request: 10101
author:
type: changed
# frozen_string_literal: true
class AddChecksumMismatchedColumndsToProjectRegistry < ActiveRecord::Migration[5.0]
DOWNTIME = false
def change
add_column :project_registry, :repository_verification_checksum_mismatched, :binary
add_column :project_registry, :wiki_verification_checksum_mismatched, :binary
end
end
......@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20181213184140) do
ActiveRecord::Schema.define(version: 20190314201959) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
......@@ -81,6 +81,8 @@ ActiveRecord::Schema.define(version: 20181213184140) do
t.integer "wiki_verification_retry_count"
t.datetime_with_timezone "last_repository_verification_ran_at"
t.datetime_with_timezone "last_wiki_verification_ran_at"
t.binary "repository_verification_checksum_mismatched"
t.binary "wiki_verification_checksum_mismatched"
t.index ["last_repository_successful_sync_at"], name: "idx_project_registry_synced_repositories_partial", where: "((resync_repository = false) AND (repository_retry_count IS NULL) AND (repository_verification_checksum_sha IS NOT NULL))", using: :btree
t.index ["last_repository_successful_sync_at"], name: "index_project_registry_on_last_repository_successful_sync_at", using: :btree
t.index ["last_repository_synced_at"], name: "index_project_registry_on_last_repository_synced_at", using: :btree
......
......@@ -79,7 +79,7 @@ describe Geo::RepositoryVerificationSecondaryService, :geo do
context 'when the checksum mismatch' do
before do
allow(repository).to receive(:checksum).and_return('other_checksum')
allow(repository).to receive(:checksum).and_return('99fc1ec4ce60')
end
it 'keeps track of failures' do
......@@ -87,6 +87,7 @@ describe Geo::RepositoryVerificationSecondaryService, :geo do
expect(registry).to have_attributes(
"#{type}_verification_checksum_sha" => nil,
"#{type}_verification_checksum_mismatched" => '99fc1ec4ce60',
"#{type}_checksum_mismatch" => true,
"last_#{type}_verification_ran_at" => be_within(1.minute).of(Time.now),
"last_#{type}_verification_failure" => "#{type.to_s.capitalize} checksum mismatch",
......@@ -120,6 +121,7 @@ describe Geo::RepositoryVerificationSecondaryService, :geo do
expect(registry).to have_attributes(
"#{type}_verification_checksum_sha" => nil,
"#{type}_verification_checksum_mismatched" => nil,
"#{type}_checksum_mismatch" => false,
"last_#{type}_verification_ran_at" => be_within(1.minute).of(Time.now),
"last_#{type}_verification_failure" => "Error calculating #{type} checksum",
......
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