Commit f6dfba53 authored by Michael Kozono's avatar Michael Kozono

Store when a registry is marked dirty

parent 6902a422
class AddResyncWasScheduledAtToProjectRegistry < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
add_column :project_registry, :resync_repository_was_scheduled_at, :datetime_with_timezone
add_column :project_registry, :resync_wiki_was_scheduled_at, :datetime_with_timezone
end
end
......@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20180510223634) do
ActiveRecord::Schema.define(version: 20180613184349) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
......@@ -76,6 +76,8 @@ ActiveRecord::Schema.define(version: 20180510223634) do
t.boolean "wiki_checksum_mismatch", default: false, null: false
t.boolean "last_repository_check_failed"
t.datetime_with_timezone "last_repository_check_at"
t.datetime_with_timezone "resync_repository_was_scheduled_at"
t.datetime_with_timezone "resync_wiki_was_scheduled_at"
end
add_index "project_registry", ["last_repository_successful_sync_at"], name: "index_project_registry_on_last_repository_successful_sync_at", using: :btree
......
......@@ -9,7 +9,7 @@ module Gitlab
registry.save!
job_id = enqueue_job_if_shard_healthy(event) do
::Geo::ProjectSyncWorker.perform_async(event.project_id, Time.now)
::Geo::ProjectSyncWorker.perform_async(event.project_id, scheduled_at)
end
log_event(job_id)
......@@ -22,7 +22,8 @@ module Gitlab
"resync_#{event.source}" => true,
"#{event.source}_verification_checksum_sha" => nil,
"#{event.source}_checksum_mismatch" => false,
"last_#{event.source}_verification_failure" => nil
"last_#{event.source}_verification_failure" => nil,
"resync_#{event.source}_was_scheduled_at" => scheduled_at
)
end
......@@ -34,8 +35,13 @@ module Gitlab
source: event.source,
resync_repository: registry.resync_repository,
resync_wiki: registry.resync_wiki,
scheduled_at: scheduled_at,
job_id: job_id)
end
def scheduled_at
@scheduled_at ||= Time.now
end
end
end
end
......
......@@ -52,6 +52,15 @@ describe Gitlab::Geo::LogCursor::Events::RepositoryUpdatedEvent, :postgresql, :c
last_repository_verification_failure: nil
)
end
it 'sets resync_repository_was_scheduled_at to the scheduled time' do
Timecop.freeze do
subject.process
reloaded_registry = registry.reload
expect(reloaded_registry.resync_repository_was_scheduled_at).to be_within(1.second).of(Time.now)
end
end
end
context 'when the event source is a wiki' do
......@@ -73,6 +82,15 @@ describe Gitlab::Geo::LogCursor::Events::RepositoryUpdatedEvent, :postgresql, :c
expect(reloaded_registry.wiki_checksum_mismatch).to be false
expect(reloaded_registry.last_wiki_verification_failure).to be_nil
end
it 'sets resync_wiki_was_scheduled_at to the scheduled time' do
Timecop.freeze do
subject.process
reloaded_registry = registry.reload
expect(reloaded_registry.resync_wiki_was_scheduled_at).to be_within(1.second).of(Time.now)
end
end
end
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