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
972d5a4c
Commit
972d5a4c
authored
Jul 27, 2018
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Track registries marked as synced when repository does not found
parent
5db71fed
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
67 additions
and
24 deletions
+67
-24
ee/app/models/geo/project_registry.rb
ee/app/models/geo/project_registry.rb
+2
-1
ee/app/services/geo/base_sync_service.rb
ee/app/services/geo/base_sync_service.rb
+2
-2
ee/app/services/geo/repository_sync_service.rb
ee/app/services/geo/repository_sync_service.rb
+1
-1
ee/app/services/geo/wiki_sync_service.rb
ee/app/services/geo/wiki_sync_service.rb
+1
-1
ee/db/geo/migrate/20180727221937_add_missing_on_primary_to_project_registry.rb
...80727221937_add_missing_on_primary_to_project_registry.rb
+8
-0
ee/db/geo/schema.rb
ee/db/geo/schema.rb
+3
-1
ee/spec/models/geo/project_registry_spec.rb
ee/spec/models/geo/project_registry_spec.rb
+32
-10
ee/spec/services/geo/repository_sync_service_spec.rb
ee/spec/services/geo/repository_sync_service_spec.rb
+9
-4
ee/spec/services/geo/wiki_sync_service_spec.rb
ee/spec/services/geo/wiki_sync_service_spec.rb
+9
-4
No files found.
ee/app/models/geo/project_registry.rb
View file @
972d5a4c
...
...
@@ -71,7 +71,7 @@ class Geo::ProjectRegistry < Geo::BaseRegistry
"
#{
type
}
_retry_at"
=>
next_retry_time
(
new_count
))
end
def
finish_sync!
(
type
)
def
finish_sync!
(
type
,
missing_on_primary
=
false
)
update!
(
# Indicate that the sync succeeded (but separately mark as synced atomically)
"last_
#{
type
}
_successful_sync_at"
=>
Time
.
now
,
...
...
@@ -79,6 +79,7 @@ class Geo::ProjectRegistry < Geo::BaseRegistry
"
#{
type
}
_retry_at"
=>
nil
,
"force_to_redownload_
#{
type
}
"
=>
false
,
"last_
#{
type
}
_sync_failure"
=>
nil
,
"
#{
type
}
_missing_on_primary"
=>
missing_on_primary
,
# Indicate that repository verification needs to be done again
"
#{
type
}
_verification_checksum_sha"
=>
nil
,
...
...
ee/app/services/geo/base_sync_service.rb
View file @
972d5a4c
...
...
@@ -126,10 +126,10 @@ module Geo
@registry
||=
Geo
::
ProjectRegistry
.
find_or_initialize_by
(
project_id:
project
.
id
)
end
def
mark_sync_as_successful
def
mark_sync_as_successful
(
missing_on_primary:
false
)
log_info
(
"Marking
#{
type
}
sync as successful"
)
persisted
=
registry
.
finish_sync!
(
type
)
persisted
=
registry
.
finish_sync!
(
type
,
missing_on_primary
)
reschedule_sync
unless
persisted
...
...
ee/app/services/geo/repository_sync_service.rb
View file @
972d5a4c
...
...
@@ -15,7 +15,7 @@ module Geo
# If it does not exist we should consider it as successfully downloaded.
if
e
.
message
.
include?
Gitlab
::
GitAccess
::
ERROR_MESSAGES
[
:no_repo
]
log_info
(
'Repository is not found, marking it as successfully synced'
)
mark_sync_as_successful
mark_sync_as_successful
(
missing_on_primary:
true
)
else
fail_registry!
(
'Error syncing repository'
,
e
)
end
...
...
ee/app/services/geo/wiki_sync_service.rb
View file @
972d5a4c
...
...
@@ -13,7 +13,7 @@ module Geo
# If it does not exist we should consider it as successfully downloaded.
if
e
.
message
.
include?
Gitlab
::
GitAccess
::
ERROR_MESSAGES
[
:no_repo
]
log_info
(
'Wiki repository is not found, marking it as successfully synced'
)
mark_sync_as_successful
mark_sync_as_successful
(
missing_on_primary:
true
)
else
fail_registry!
(
'Error syncing wiki repository'
,
e
)
end
...
...
ee/db/geo/migrate/20180727221937_add_missing_on_primary_to_project_registry.rb
0 → 100644
View file @
972d5a4c
# frozen_string_literal: true
class
AddMissingOnPrimaryToProjectRegistry
<
ActiveRecord
::
Migration
def
change
add_column
:project_registry
,
:repository_missing_on_primary
,
:boolean
add_column
:project_registry
,
:wiki_missing_on_primary
,
:boolean
end
end
ee/db/geo/schema.rb
View file @
972d5a4c
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
20180
613184349
)
do
ActiveRecord
::
Schema
.
define
(
version:
20180
727221937
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
@@ -78,6 +78,8 @@ ActiveRecord::Schema.define(version: 20180613184349) do
t
.
datetime_with_timezone
"last_repository_check_at"
t
.
datetime_with_timezone
"resync_repository_was_scheduled_at"
t
.
datetime_with_timezone
"resync_wiki_was_scheduled_at"
t
.
boolean
"repository_missing_on_primary"
t
.
boolean
"wiki_missing_on_primary"
end
add_index
"project_registry"
,
[
"last_repository_successful_sync_at"
],
name:
"index_project_registry_on_last_repository_successful_sync_at"
,
using: :btree
...
...
ee/spec/models/geo/project_registry_spec.rb
View file @
972d5a4c
...
...
@@ -406,11 +406,14 @@ describe Geo::ProjectRegistry do
it
'resets sync state'
do
subject
.
finish_sync!
(
type
)
expect
(
subject
.
reload
.
resync_repository
).
to
be
false
expect
(
subject
.
reload
.
repository_retry_count
).
to
be_nil
expect
(
subject
.
reload
.
repository_retry_at
).
to
be_nil
expect
(
subject
.
reload
.
force_to_redownload_repository
).
to
be
false
expect
(
subject
.
reload
.
last_repository_sync_failure
).
to
be_nil
expect
(
subject
.
reload
).
to
have_attributes
(
resync_repository:
false
,
repository_retry_count:
be_nil
,
repository_retry_at:
be_nil
,
force_to_redownload_repository:
false
,
last_repository_sync_failure:
be_nil
,
repository_missing_on_primary:
false
)
end
it
'resets verification state'
do
...
...
@@ -421,6 +424,14 @@ describe Geo::ProjectRegistry do
expect
(
subject
.
reload
.
last_repository_verification_failure
).
to
be_nil
end
context
'when a repository was missing on primary'
do
it
'sets repository_missing_on_primary as true'
do
subject
.
finish_sync!
(
type
,
true
)
expect
(
subject
.
reload
.
repository_missing_on_primary
).
to
be
true
end
end
context
'when a repository sync was scheduled after the last sync began'
do
before
do
subject
.
update!
(
resync_repository_was_scheduled_at:
subject
.
last_repository_synced_at
+
1
.
minute
)
...
...
@@ -470,11 +481,14 @@ describe Geo::ProjectRegistry do
it
'resets sync state'
do
subject
.
finish_sync!
(
type
)
expect
(
subject
.
reload
.
resync_wiki
).
to
be
false
expect
(
subject
.
reload
.
wiki_retry_count
).
to
be_nil
expect
(
subject
.
reload
.
wiki_retry_at
).
to
be_nil
expect
(
subject
.
reload
.
force_to_redownload_wiki
).
to
be
false
expect
(
subject
.
reload
.
last_wiki_sync_failure
).
to
be_nil
expect
(
subject
.
reload
).
to
have_attributes
(
resync_wiki:
false
,
wiki_retry_count:
be_nil
,
wiki_retry_at:
be_nil
,
force_to_redownload_wiki:
false
,
last_wiki_sync_failure:
be_nil
,
wiki_missing_on_primary:
false
)
end
it
'resets verification state'
do
...
...
@@ -485,6 +499,14 @@ describe Geo::ProjectRegistry do
expect
(
subject
.
reload
.
last_wiki_verification_failure
).
to
be_nil
end
context
'when a wiki was missing on primary'
do
it
'sets wiki_missing_on_primary as true'
do
subject
.
finish_sync!
(
type
,
true
)
expect
(
subject
.
reload
.
wiki_missing_on_primary
).
to
be
true
end
end
context
'when a wiki sync was scheduled after the last sync began'
do
before
do
subject
.
update!
(
resync_wiki_was_scheduled_at:
subject
.
last_wiki_synced_at
+
1
.
minute
)
...
...
ee/spec/services/geo/repository_sync_service_spec.rb
View file @
972d5a4c
...
...
@@ -105,8 +105,10 @@ describe Geo::RepositorySyncService do
subject
.
execute
expect
(
Geo
::
ProjectRegistry
.
last
.
resync_repository
).
to
be
true
expect
(
Geo
::
ProjectRegistry
.
last
.
repository_retry_count
).
to
eq
(
1
)
expect
(
Geo
::
ProjectRegistry
.
last
).
to
have_attributes
(
resync_repository:
true
,
repository_retry_count:
1
)
end
it
'marks sync as successful if no repository found'
do
...
...
@@ -118,8 +120,11 @@ describe Geo::RepositorySyncService do
subject
.
execute
expect
(
registry
.
reload
.
resync_repository
).
to
be
false
expect
(
registry
.
reload
.
last_repository_successful_sync_at
).
not_to
be
nil
expect
(
registry
.
reload
).
to
have_attributes
(
resync_repository:
false
,
last_repository_successful_sync_at:
be_present
,
repository_missing_on_primary:
true
)
end
it
'marks resync as true after a failure'
do
...
...
ee/spec/services/geo/wiki_sync_service_spec.rb
View file @
972d5a4c
...
...
@@ -84,8 +84,10 @@ RSpec.describe Geo::WikiSyncService do
subject
.
execute
expect
(
Geo
::
ProjectRegistry
.
last
.
resync_wiki
).
to
be
true
expect
(
Geo
::
ProjectRegistry
.
last
.
wiki_retry_count
).
to
eq
(
1
)
expect
(
Geo
::
ProjectRegistry
.
last
).
to
have_attributes
(
resync_wiki:
true
,
wiki_retry_count:
1
)
end
it
'marks sync as successful if no repository found'
do
...
...
@@ -97,8 +99,11 @@ RSpec.describe Geo::WikiSyncService do
subject
.
execute
expect
(
registry
.
reload
.
resync_wiki
).
to
be
false
expect
(
registry
.
last_wiki_successful_sync_at
).
not_to
be
nil
expect
(
registry
.
reload
).
to
have_attributes
(
resync_wiki:
false
,
last_wiki_successful_sync_at:
be_present
,
wiki_missing_on_primary:
true
)
end
it
'marks resync as true after a failure'
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