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
4d93cf99
Commit
4d93cf99
authored
Mar 09, 2021
by
Mike Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Nest Geo::VerifiableRegistry module
See
https://gitlab.com/gitlab-org/gitlab/-/issues/39044
parent
84dbfc94
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
60 deletions
+62
-60
ee/app/models/concerns/geo/verifiable_registry.rb
ee/app/models/concerns/geo/verifiable_registry.rb
+62
-60
No files found.
ee/app/models/concerns/geo/verifiable_registry.rb
View file @
4d93cf99
# frozen_string_literal: true
module
Geo::VerifiableRegistry
extend
ActiveSupport
::
Concern
class_methods
do
extend
::
Gitlab
::
Utils
::
Override
# Overrides a method in `Gitlab::Geo::VerificationState`. This method is
# used by `Gitlab::Geo::VerificationState.start_verification_batch` to
# produce a query which must return values of the primary key of the
# *model*, not of the *registry*. We need this so we can instantiate
# Replicators.
override
:verification_state_model_key
def
verification_state_model_key
self
::
MODEL_FOREIGN_KEY
end
module
Geo
module
VerifiableRegistry
extend
ActiveSupport
::
Concern
class_methods
do
extend
::
Gitlab
::
Utils
::
Override
# Overrides a method in `Gitlab::Geo::VerificationState`. This method is
# used by `Gitlab::Geo::VerificationState.start_verification_batch` to
# produce a query which must return values of the primary key of the
# *model*, not of the *registry*. We need this so we can instantiate
# Replicators.
override
:verification_state_model_key
def
verification_state_model_key
self
::
MODEL_FOREIGN_KEY
end
override
:verification_pending_batch_relation
def
verification_pending_batch_relation
(
batch_size
:)
super
.
synced
end
override
:verification_pending_batch_relation
def
verification_pending_batch_relation
(
batch_size
:)
super
.
synced
end
override
:verification_failed_batch_relation
def
verification_failed_batch_relation
(
batch_size
:)
super
.
synced
end
override
:verification_failed_batch_relation
def
verification_failed_batch_relation
(
batch_size
:)
super
.
synced
end
override
:needs_verification_relation
def
needs_verification_relation
super
.
synced
override
:needs_verification_relation
def
needs_verification_relation
super
.
synced
end
end
end
included
do
extend
::
Gitlab
::
Utils
::
Override
included
do
extend
::
Gitlab
::
Utils
::
Override
sha_attribute
:verification_checksum_mismatched
scope
:available_verifiables
,
->
{
all
}
sha_attribute
:verification_checksum_mismatched
scope
:available_verifiables
,
->
{
all
}
override
:clear_verification_failure_fields!
def
clear_verification_failure_fields!
super
override
:clear_verification_failure_fields!
def
clear_verification_failure_fields!
super
# Note: If the return value of a `before_transition` block is `false`,
# then the transition is halted. Anything else, including `nil`, does not
# halt the transition.
self
.
checksum_mismatch
=
false
self
.
verification_checksum_mismatched
=
nil
end
# Note: If the return value of a `before_transition` block is `false`,
# then the transition is halted. Anything else, including `nil`, does not
# halt the transition.
self
.
checksum_mismatch
=
false
self
.
verification_checksum_mismatched
=
nil
end
# Records a checksum mismatch
#
# @param [String] checksum value which does not match the primary checksum
def
verification_failed_due_to_mismatch!
(
checksum
,
primary_checksum
)
message
=
'Checksum does not match the primary checksum'
details
=
{
checksum:
checksum
,
primary_checksum:
primary_checksum
}
# Records a checksum mismatch
#
# @param [String] checksum value which does not match the primary checksum
def
verification_failed_due_to_mismatch!
(
checksum
,
primary_checksum
)
message
=
'Checksum does not match the primary checksum'
details
=
{
checksum:
checksum
,
primary_checksum:
primary_checksum
}
log_info
(
message
,
details
)
log_info
(
message
,
details
)
self
.
verification_failure
=
"
#{
message
}
#{
details
}
"
.
truncate
(
255
)
self
.
verification_checksum
=
checksum
self
.
verification_checksum_mismatched
=
checksum
self
.
checksum_mismatch
=
true
self
.
verification_failure
=
"
#{
message
}
#{
details
}
"
.
truncate
(
255
)
self
.
verification_checksum
=
checksum
self
.
verification_checksum_mismatched
=
checksum
self
.
checksum_mismatch
=
true
self
.
verification_failed!
end
self
.
verification_failed!
end
private
private
override
:track_checksum_result!
def
track_checksum_result!
(
checksum
,
calculation_started_at
)
unless
replicator
.
matches_checksum?
(
checksum
)
return
verification_failed_due_to_mismatch!
(
checksum
,
replicator
.
primary_checksum
)
end
override
:track_checksum_result!
def
track_checksum_result!
(
checksum
,
calculation_started_at
)
unless
replicator
.
matches_checksum?
(
checksum
)
return
verification_failed_due_to_mismatch!
(
checksum
,
replicator
.
primary_checksum
)
end
verification_succeeded_with_checksum!
(
checksum
,
calculation_started_at
)
verification_succeeded_with_checksum!
(
checksum
,
calculation_started_at
)
end
end
end
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