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
22e6683b
Commit
22e6683b
authored
Nov 21, 2017
by
James Lopez
Committed by
Nick Thomas
Nov 21, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix in-progress repository syncs counting as failed
parent
1f95183f
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
39 additions
and
7 deletions
+39
-7
app/models/geo/project_registry.rb
app/models/geo/project_registry.rb
+2
-5
app/services/geo/repository_sync_service.rb
app/services/geo/repository_sync_service.rb
+7
-1
app/services/geo/wiki_sync_service.rb
app/services/geo/wiki_sync_service.rb
+7
-1
changelogs/unreleased-ee/fix-geo-failed-repo-count.yml
changelogs/unreleased-ee/fix-geo-failed-repo-count.yml
+5
-0
spec/factories/geo/project_registry.rb
spec/factories/geo/project_registry.rb
+13
-0
spec/models/geo/project_registry_spec.rb
spec/models/geo/project_registry_spec.rb
+3
-0
spec/models/geo_node_status_spec.rb
spec/models/geo_node_status_spec.rb
+2
-0
No files found.
app/models/geo/project_registry.rb
View file @
22e6683b
...
@@ -6,11 +6,8 @@ class Geo::ProjectRegistry < Geo::BaseRegistry
...
@@ -6,11 +6,8 @@ class Geo::ProjectRegistry < Geo::BaseRegistry
scope
:dirty
,
->
{
where
(
arel_table
[
:resync_repository
].
eq
(
true
).
or
(
arel_table
[
:resync_wiki
].
eq
(
true
)))
}
scope
:dirty
,
->
{
where
(
arel_table
[
:resync_repository
].
eq
(
true
).
or
(
arel_table
[
:resync_wiki
].
eq
(
true
)))
}
def
self
.
failed
def
self
.
failed
repository_sync_failed
=
arel_table
[
:last_repository_synced_at
].
not_eq
(
nil
)
repository_sync_failed
=
arel_table
[
:repository_retry_count
].
gt
(
0
)
.
and
(
arel_table
[
:last_repository_successful_sync_at
].
eq
(
nil
))
wiki_sync_failed
=
arel_table
[
:wiki_retry_count
].
gt
(
0
)
wiki_sync_failed
=
arel_table
[
:last_wiki_synced_at
].
not_eq
(
nil
)
.
and
(
arel_table
[
:last_wiki_successful_sync_at
].
eq
(
nil
))
where
(
repository_sync_failed
.
or
(
wiki_sync_failed
))
where
(
repository_sync_failed
.
or
(
wiki_sync_failed
))
end
end
...
...
app/services/geo/repository_sync_service.rb
View file @
22e6683b
...
@@ -30,10 +30,12 @@ module Geo
...
@@ -30,10 +30,12 @@ module Geo
Gitlab
::
Git
::
RepositoryMirroring
::
RemoteError
,
Gitlab
::
Git
::
RepositoryMirroring
::
RemoteError
,
Geo
::
EmptyCloneUrlPrefixError
=>
e
Geo
::
EmptyCloneUrlPrefixError
=>
e
log_error
(
'Error syncing repository'
,
e
)
log_error
(
'Error syncing repository'
,
e
)
registry
.
increment!
(
:repository_retry_count
)
rescue
Gitlab
::
Git
::
Repository
::
NoRepository
=>
e
rescue
Gitlab
::
Git
::
Repository
::
NoRepository
=>
e
log_error
(
'Invalid repository'
,
e
)
log_error
(
'Invalid repository'
,
e
)
log_info
(
'Setting force_to_redownload flag'
)
log_info
(
'Setting force_to_redownload flag'
)
registry
.
update
(
force_to_redownload_repository:
true
)
registry
.
update
(
force_to_redownload_repository:
true
,
repository_retry_count:
retry_count
+
1
)
log_info
(
'Expiring caches'
)
log_info
(
'Expiring caches'
)
project
.
repository
.
after_create
project
.
repository
.
after_create
ensure
ensure
...
@@ -52,5 +54,9 @@ module Geo
...
@@ -52,5 +54,9 @@ module Geo
def
repository
def
repository
project
.
repository
project
.
repository
end
end
def
retry_count
registry
.
public_send
(
"
#{
type
}
_retry_count"
)
||
-
1
# rubocop:disable GitlabSecurity/PublicSend
end
end
end
end
end
app/services/geo/wiki_sync_service.rb
View file @
22e6683b
...
@@ -33,9 +33,11 @@ module Geo
...
@@ -33,9 +33,11 @@ module Geo
ProjectWiki
::
CouldNotCreateWikiError
,
ProjectWiki
::
CouldNotCreateWikiError
,
Geo
::
EmptyCloneUrlPrefixError
=>
e
Geo
::
EmptyCloneUrlPrefixError
=>
e
log_error
(
'Error syncing wiki repository'
,
e
)
log_error
(
'Error syncing wiki repository'
,
e
)
registry
.
increment!
(
:wiki_retry_count
)
rescue
Gitlab
::
Git
::
Repository
::
NoRepository
=>
e
rescue
Gitlab
::
Git
::
Repository
::
NoRepository
=>
e
log_error
(
'Invalid wiki'
,
e
)
log_error
(
'Invalid wiki'
,
e
)
registry
.
update
(
force_to_redownload_wiki:
true
)
registry
.
update
(
force_to_redownload_wiki:
true
,
repository_retry_count:
retry_count
+
1
)
ensure
ensure
clean_up_temporary_repository
if
redownload
clean_up_temporary_repository
if
redownload
end
end
...
@@ -47,5 +49,9 @@ module Geo
...
@@ -47,5 +49,9 @@ module Geo
def
repository
def
repository
project
.
wiki
.
repository
project
.
wiki
.
repository
end
end
def
retry_count
registry
.
public_send
(
"
#{
type
}
_retry_count"
)
||
-
1
# rubocop:disable GitlabSecurity/PublicSend
end
end
end
end
end
changelogs/unreleased-ee/fix-geo-failed-repo-count.yml
0 → 100644
View file @
22e6683b
---
title
:
Fix in-progress repository syncs counting as failed
merge_request
:
3424
author
:
type
:
fixed
spec/factories/geo/project_registry.rb
View file @
22e6683b
...
@@ -39,6 +39,7 @@ FactoryGirl.define do
...
@@ -39,6 +39,7 @@ FactoryGirl.define do
last_wiki_successful_sync_at
nil
last_wiki_successful_sync_at
nil
resync_repository
true
resync_repository
true
resync_wiki
true
resync_wiki
true
repository_retry_count
1
end
end
trait
:repository_sync_failed
do
trait
:repository_sync_failed
do
...
@@ -48,6 +49,12 @@ FactoryGirl.define do
...
@@ -48,6 +49,12 @@ FactoryGirl.define do
last_wiki_successful_sync_at
{
5
.
days
.
ago
}
last_wiki_successful_sync_at
{
5
.
days
.
ago
}
resync_repository
true
resync_repository
true
resync_wiki
false
resync_wiki
false
repository_retry_count
1
end
trait
:repository_syncing
do
repository_sync_failed
repository_retry_count
0
end
end
trait
:wiki_sync_failed
do
trait
:wiki_sync_failed
do
...
@@ -57,6 +64,12 @@ FactoryGirl.define do
...
@@ -57,6 +64,12 @@ FactoryGirl.define do
last_wiki_successful_sync_at
nil
last_wiki_successful_sync_at
nil
resync_repository
false
resync_repository
false
resync_wiki
true
resync_wiki
true
wiki_retry_count
2
end
trait
:wiki_syncing
do
wiki_sync_failed
wiki_retry_count
0
end
end
end
end
end
end
spec/models/geo/project_registry_spec.rb
View file @
22e6683b
...
@@ -21,6 +21,9 @@ describe Geo::ProjectRegistry do
...
@@ -21,6 +21,9 @@ describe Geo::ProjectRegistry do
it
'returns projects where last attempt to sync failed'
do
it
'returns projects where last attempt to sync failed'
do
create
(
:geo_project_registry
,
:synced
)
create
(
:geo_project_registry
,
:synced
)
create
(
:geo_project_registry
,
:synced
,
:dirty
)
create
(
:geo_project_registry
,
:synced
,
:dirty
)
create
(
:geo_project_registry
,
:repository_syncing
)
create
(
:geo_project_registry
,
:wiki_syncing
)
repository_sync_failed
=
create
(
:geo_project_registry
,
:repository_sync_failed
)
repository_sync_failed
=
create
(
:geo_project_registry
,
:repository_sync_failed
)
wiki_sync_failed
=
create
(
:geo_project_registry
,
:wiki_sync_failed
)
wiki_sync_failed
=
create
(
:geo_project_registry
,
:wiki_sync_failed
)
...
...
spec/models/geo_node_status_spec.rb
View file @
22e6683b
...
@@ -200,6 +200,8 @@ describe GeoNodeStatus, :geo do
...
@@ -200,6 +200,8 @@ describe GeoNodeStatus, :geo do
before
do
before
do
create
(
:geo_project_registry
,
:sync_failed
,
project:
project_1
)
create
(
:geo_project_registry
,
:sync_failed
,
project:
project_1
)
create
(
:geo_project_registry
,
:sync_failed
,
project:
project_3
)
create
(
:geo_project_registry
,
:sync_failed
,
project:
project_3
)
create
(
:geo_project_registry
,
:repository_syncing
,
project:
project_4
)
create
(
:geo_project_registry
,
:wiki_syncing
)
end
end
it
'returns the right number of failed repos with no group restrictions'
do
it
'returns the right number of failed repos with no group restrictions'
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