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
c5d195e7
Commit
c5d195e7
authored
Apr 11, 2018
by
Douglas Barbosa Alexandre
Committed by
Nick Thomas
Apr 11, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "Geo: Wiki repository verification is broken"
parent
5a15ca02
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
28 deletions
+32
-28
ee/app/services/geo/repository_verify_secondary_service.rb
ee/app/services/geo/repository_verify_secondary_service.rb
+12
-22
ee/changelogs/unreleased/5619-geo-wiki-repository-verification-is-broken.yml
...eased/5619-geo-wiki-repository-verification-is-broken.yml
+5
-0
ee/spec/services/geo/repository_verify_secondary_service_spec.rb
.../services/geo/repository_verify_secondary_service_spec.rb
+15
-6
No files found.
ee/app/services/geo/repository_verify_secondary_service.rb
View file @
c5d195e7
...
@@ -2,8 +2,6 @@ module Geo
...
@@ -2,8 +2,6 @@ module Geo
class
RepositoryVerifySecondaryService
class
RepositoryVerifySecondaryService
include
Gitlab
::
Geo
::
ProjectLogHelpers
include
Gitlab
::
Geo
::
ProjectLogHelpers
delegate
:project
,
to: :registry
def
initialize
(
registry
,
type
)
def
initialize
(
registry
,
type
)
@registry
=
registry
@registry
=
registry
@type
=
type
.
to_sym
@type
=
type
.
to_sym
...
@@ -21,6 +19,8 @@ module Geo
...
@@ -21,6 +19,8 @@ module Geo
attr_reader
:registry
,
:type
attr_reader
:registry
,
:type
delegate
:project
,
to: :registry
def
should_verify_checksum?
def
should_verify_checksum?
return
false
if
resync?
return
false
if
resync?
...
@@ -40,15 +40,15 @@ module Geo
...
@@ -40,15 +40,15 @@ module Geo
end
end
def
verify_checksum
def
verify_checksum
checksum
=
project
.
repository
.
checksum
checksum
=
repository
.
checksum
if
mismatch?
(
checksum
)
if
mismatch?
(
checksum
)
update_registry!
(
failure:
"
#{
type
.
to_s
.
capitalize
}
checksum mismatch:
#{
repository_path
}
"
)
update_registry!
(
failure:
"
#{
type
.
to_s
.
capitalize
}
checksum mismatch:
#{
repository
.
disk
_path
}
"
)
else
else
update_registry!
(
checksum:
checksum
)
update_registry!
(
checksum:
checksum
)
end
end
rescue
::
Gitlab
::
Git
::
Repository
::
NoRepository
,
::
Gitlab
::
Git
::
Repository
::
ChecksumError
,
Timeout
::
Error
=>
e
rescue
::
Gitlab
::
Git
::
Repository
::
NoRepository
,
::
Gitlab
::
Git
::
Repository
::
ChecksumError
,
Timeout
::
Error
=>
e
update_registry!
(
failure:
"Error verifying
#{
type
.
to_s
.
capitalize
}
checksum:
#{
repository_path
}
"
,
exception:
e
)
update_registry!
(
failure:
"Error verifying
#{
type
.
to_s
.
capitalize
}
checksum:
#{
repository
.
disk
_path
}
"
,
exception:
e
)
end
end
def
mismatch?
(
checksum
)
def
mismatch?
(
checksum
)
...
@@ -62,28 +62,18 @@ module Geo
...
@@ -62,28 +62,18 @@ module Geo
}
}
if
failure
if
failure
log_error
(
failure
,
exception
,
type:
type
,
repository_full_path:
path_to_repo
)
log_error
(
failure
,
exception
,
type:
type
,
repository_full_path:
repository
.
path_to_repo
)
end
end
registry
.
update!
(
attrs
)
registry
.
update!
(
attrs
)
end
end
def
repository_path
def
repository
case
type
@repository
||=
when
:repository
case
type
registry
.
project
.
disk_path
when
:repository
then
project
.
repository
when
:wiki
when
:wiki
then
project
.
wiki
.
repository
registry
.
project
.
wiki
.
disk_path
end
end
end
def
path_to_repo
case
type
when
:repository
project
.
repository
.
path_to_repo
when
:wiki
project
.
wiki
.
repository
.
path_to_repo
end
end
end
end
end
end
end
ee/changelogs/unreleased/5619-geo-wiki-repository-verification-is-broken.yml
0 → 100644
View file @
c5d195e7
---
title
:
Geo - Fix wiki repository verification on a secondary node
merge_request
:
5315
author
:
type
:
fixed
ee/spec/services/geo/repository_verify_secondary_service_spec.rb
View file @
c5d195e7
...
@@ -10,12 +10,14 @@ describe Geo::RepositoryVerifySecondaryService, :geo do
...
@@ -10,12 +10,14 @@ describe Geo::RepositoryVerifySecondaryService, :geo do
end
end
shared_examples
'verify checksums for repositories/wikis'
do
|
type
|
shared_examples
'verify checksums for repositories/wikis'
do
|
type
|
let
(
:repository
)
{
find_repository
(
type
)
}
subject
(
:service
)
{
described_class
.
new
(
registry
,
type
)
}
subject
(
:service
)
{
described_class
.
new
(
registry
,
type
)
}
it
'does not calculate the checksum when not running on a secondary'
do
it
'does not calculate the checksum when not running on a secondary'
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:secondary?
)
{
false
}
allow
(
Gitlab
::
Geo
).
to
receive
(
:secondary?
)
{
false
}
expect
(
re
gistry
.
project
.
re
pository
).
not_to
receive
(
:checksum
)
expect
(
repository
).
not_to
receive
(
:checksum
)
service
.
execute
service
.
execute
end
end
...
@@ -23,7 +25,7 @@ describe Geo::RepositoryVerifySecondaryService, :geo do
...
@@ -23,7 +25,7 @@ describe Geo::RepositoryVerifySecondaryService, :geo do
it
'does not verify the checksum if resync is needed'
do
it
'does not verify the checksum if resync is needed'
do
registry
.
assign_attributes
(
"resync_
#{
type
}
"
=>
true
)
registry
.
assign_attributes
(
"resync_
#{
type
}
"
=>
true
)
expect
(
re
gistry
.
project
.
re
pository
).
not_to
receive
(
:checksum
)
expect
(
repository
).
not_to
receive
(
:checksum
)
service
.
execute
service
.
execute
end
end
...
@@ -31,7 +33,7 @@ describe Geo::RepositoryVerifySecondaryService, :geo do
...
@@ -31,7 +33,7 @@ describe Geo::RepositoryVerifySecondaryService, :geo do
it
'does not verify the checksum if primary was never verified'
do
it
'does not verify the checksum if primary was never verified'
do
repository_state
.
assign_attributes
(
"
#{
type
}
_verification_checksum"
=>
nil
)
repository_state
.
assign_attributes
(
"
#{
type
}
_verification_checksum"
=>
nil
)
expect
(
re
gistry
.
project
.
re
pository
).
not_to
receive
(
:checksum
)
expect
(
repository
).
not_to
receive
(
:checksum
)
service
.
execute
service
.
execute
end
end
...
@@ -40,24 +42,31 @@ describe Geo::RepositoryVerifySecondaryService, :geo do
...
@@ -40,24 +42,31 @@ describe Geo::RepositoryVerifySecondaryService, :geo do
repository_state
.
assign_attributes
(
"
#{
type
}
_verification_checksum"
=>
'my_checksum'
)
repository_state
.
assign_attributes
(
"
#{
type
}
_verification_checksum"
=>
'my_checksum'
)
registry
.
assign_attributes
(
"
#{
type
}
_verification_checksum_sha"
=>
'my_checksum'
)
registry
.
assign_attributes
(
"
#{
type
}
_verification_checksum_sha"
=>
'my_checksum'
)
expect
(
re
gistry
.
project
.
re
pository
).
not_to
receive
(
:checksum
)
expect
(
repository
).
not_to
receive
(
:checksum
)
service
.
execute
service
.
execute
end
end
it
'sets checksum when the checksum matches'
do
it
'sets checksum when the checksum matches'
do
expect
(
re
gistry
.
project
.
re
pository
).
to
receive
(
:checksum
).
and_return
(
'my_checksum'
)
expect
(
repository
).
to
receive
(
:checksum
).
and_return
(
'my_checksum'
)
expect
{
service
.
execute
}.
to
change
(
registry
,
"
#{
type
}
_verification_checksum_sha"
)
expect
{
service
.
execute
}.
to
change
(
registry
,
"
#{
type
}
_verification_checksum_sha"
)
.
from
(
nil
).
to
(
'my_checksum'
)
.
from
(
nil
).
to
(
'my_checksum'
)
end
end
it
'keeps track of failure when the checksum mismatch'
do
it
'keeps track of failure when the checksum mismatch'
do
expect
(
re
gistry
.
project
.
re
pository
).
to
receive
(
:checksum
).
and_return
(
'other_checksum'
)
expect
(
repository
).
to
receive
(
:checksum
).
and_return
(
'other_checksum'
)
expect
{
service
.
execute
}.
to
change
(
registry
,
"last_
#{
type
}
_verification_failure"
)
expect
{
service
.
execute
}.
to
change
(
registry
,
"last_
#{
type
}
_verification_failure"
)
.
from
(
nil
).
to
(
/
#{
Regexp
.
quote
(
type
.
to_s
.
capitalize
)
}
checksum mismatch/
)
.
from
(
nil
).
to
(
/
#{
Regexp
.
quote
(
type
.
to_s
.
capitalize
)
}
checksum mismatch/
)
end
end
def
find_repository
(
type
)
case
type
when
:repository
then
project
.
repository
when
:wiki
then
project
.
wiki
.
repository
end
end
end
end
describe
'#execute'
do
describe
'#execute'
do
...
...
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