Successful sync should cause verification

This is needed to support:

1. Verification of mutable types
2. Automatic healing of verification failures

Changelog: changed
EE: true
parent d2c64354
......@@ -513,6 +513,12 @@ That's all of the required database changes.
last_synced_at { 1.day.ago }
retry_count { 0 }
end
trait :verification_succeeded do
verification_checksum { 'e079a831cab27bcda7d81cd9b48296d0c3dd92ef' }
verification_state { Geo::CoolWidgetRegistry.verification_state_value(:verification_succeeded) }
verified_at { 5.days.ago }
end
end
end
```
......
......@@ -479,6 +479,12 @@ That's all of the required database changes.
last_synced_at { 1.day.ago }
retry_count { 0 }
end
trait :verification_succeeded do
verification_checksum { 'e079a831cab27bcda7d81cd9b48296d0c3dd92ef' }
verification_state { Geo::CoolWidgetRegistry.verification_state_value(:verification_succeeded) }
verified_at { 5.days.ago }
end
end
end
```
......
......@@ -44,6 +44,11 @@ module Geo::ReplicableRegistry
end
end
# Overridden by Geo::VerifiableRegistry
def after_synced
# No-op
end
def replicator_class
Gitlab::Geo::Replicator.for_class_name(self)
end
......@@ -86,6 +91,10 @@ module Geo::ReplicableRegistry
registry.retry_at = nil
end
after_transition any => :synced do |registry, _|
registry.after_synced
end
event :start do
transition [:pending, :synced, :failed] => :started
end
......
......@@ -3,6 +3,7 @@
module Geo
module VerifiableRegistry
extend ActiveSupport::Concern
extend ::Gitlab::Utils::Override
include ::Gitlab::Geo::VerificationState
class_methods do
......@@ -79,5 +80,10 @@ module Geo
verification_succeeded_with_checksum!(checksum, calculation_started_at)
end
end
override :after_synced
def after_synced
self.verification_pending!
end
end
end
......@@ -270,7 +270,7 @@ module Gitlab
end
end
# Overridden by ReplicableRegistry
# Overridden by Geo::VerifiableRegistry
def clear_verification_failure_fields!
self.verification_retry_count = 0
self.verification_retry_at = nil
......
......@@ -22,5 +22,11 @@ FactoryBot.define do
last_synced_at { 1.day.ago }
retry_count { 0 }
end
trait :verification_succeeded do
verification_checksum { 'e079a831cab27bcda7d81cd9b48296d0c3dd92ef' }
verification_state { Geo::PackageFileRegistry.verification_state_value(:verification_succeeded) }
verified_at { 5.days.ago }
end
end
end
......@@ -22,5 +22,11 @@ FactoryBot.define do
last_synced_at { 1.day.ago }
retry_count { 0 }
end
trait :verification_succeeded do
verification_checksum { 'e079a831cab27bcda7d81cd9b48296d0c3dd92ef' }
verification_state { Geo::PipelineArtifactRegistry.verification_state_value(:verification_succeeded) }
verified_at { 5.days.ago }
end
end
end
......@@ -22,5 +22,11 @@ FactoryBot.define do
last_synced_at { 1.day.ago }
retry_count { 0 }
end
trait :verification_succeeded do
verification_checksum { 'e079a831cab27bcda7d81cd9b48296d0c3dd92ef' }
verification_state { Geo::SnippetRepositoryRegistry.verification_state_value(:verification_succeeded) }
verified_at { 5.days.ago }
end
end
end
......@@ -22,5 +22,11 @@ FactoryBot.define do
last_synced_at { 1.day.ago }
retry_count { 0 }
end
trait :verification_succeeded do
verification_checksum { 'e079a831cab27bcda7d81cd9b48296d0c3dd92ef' }
verification_state { Geo::TerraformStateVersionRegistry.verification_state_value(:verification_succeeded) }
verified_at { 5.days.ago }
end
end
end
......@@ -7,6 +7,18 @@ RSpec.shared_examples 'a Geo verifiable registry' do
subject(:registry_record) { create(registry_class_factory, :synced) }
context 'state machine' do
context 'when transitioning to synced' do
it 'marks verification as pending' do
registry = create(registry_class_factory, :started, :verification_succeeded)
registry.synced!
expect(registry.reload).to be_verification_pending
end
end
end
describe '.verification_pending_batch' do
before do
subject.save!
......
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