Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
33c8dfbd
Commit
33c8dfbd
authored
Feb 03, 2021
by
Mike Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor: Move needs_checksum? logic
into `should_primary_verify?`
parent
33acd0ea
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
21 deletions
+15
-21
ee/app/models/concerns/geo/verifiable_replicator.rb
ee/app/models/concerns/geo/verifiable_replicator.rb
+11
-9
ee/lib/gitlab/geo/replicable_model.rb
ee/lib/gitlab/geo/replicable_model.rb
+0
-11
ee/spec/support/shared_examples/models/concerns/verifiable_replicator_shared_examples.rb
.../models/concerns/verifiable_replicator_shared_examples.rb
+4
-1
No files found.
ee/app/models/concerns/geo/verifiable_replicator.rb
View file @
33c8dfbd
...
...
@@ -118,8 +118,9 @@ module Geo
end
end
# Schedules a verification job after a model record is created/updated
def
after_verifiable_update
verify_async
if
needs_checksum
?
verify_async
if
should_primary_verify
?
end
def
verify_async
...
...
@@ -146,14 +147,7 @@ module Geo
# @param [String] checksum
# @return [Boolean] whether checksum matches
def
matches_checksum?
(
checksum
)
model_record
.
verification_checksum
==
checksum
end
def
needs_checksum?
return
false
unless
self
.
class
.
verification_enabled?
return
true
unless
model_record
.
respond_to?
(
:needs_checksum?
)
model_record
.
needs_checksum?
primary_checksum
==
checksum
end
# Checksum value from the main database
...
...
@@ -170,5 +164,13 @@ module Geo
def
verification_state_tracker
Gitlab
::
Geo
.
secondary?
?
registry
:
model_record
end
private
def
should_primary_verify?
self
.
class
.
verification_enabled?
&&
primary_checksum
.
nil?
&&
# Some models may populate this as part of creating the record
model_record
.
checksummable?
end
end
end
ee/lib/gitlab/geo/replicable_model.rb
View file @
33c8dfbd
...
...
@@ -57,17 +57,6 @@ module Gitlab
self
.
class
.
hexdigest
(
replicator
.
carrierwave_uploader
.
path
)
end
# Checks whether model needs checksum to be performed
#
# Conditions:
# - No checksum is present
# - It's capable of generating a checksum of itself
#
# @return [Boolean]
def
needs_checksum?
verification_checksum
.
nil?
&&
checksummable?
end
# Return whether its capable of generating a checksum of itself
#
# @return [Boolean] whether it can generate a checksum
...
...
ee/spec/support/shared_examples/models/concerns/verifiable_replicator_shared_examples.rb
View file @
33c8dfbd
...
...
@@ -299,8 +299,11 @@ RSpec.shared_examples 'a verifiable replicator' do
describe
'#after_verifiable_update'
do
it
'calls verify_async if needed'
do
allow
(
described_class
).
to
receive
(
:verification_enabled?
).
and_return
(
true
)
allow
(
replicator
).
to
receive
(
:primary_checksum
).
and_return
(
nil
)
allow
(
model_record
).
to
receive
(
:checksummable?
).
and_return
(
true
)
expect
(
replicator
).
to
receive
(
:verify_async
)
expect
(
replicator
).
to
receive
(
:needs_checksum?
).
and_return
(
true
)
replicator
.
after_verifiable_update
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment