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
6829b846
Commit
6829b846
authored
Mar 23, 2018
by
Michael Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mark disabled wiki as fully synced
parent
73d1fab8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
8 deletions
+61
-8
ee/app/workers/geo/project_sync_worker.rb
ee/app/workers/geo/project_sync_worker.rb
+17
-5
ee/spec/workers/geo/project_sync_worker_spec.rb
ee/spec/workers/geo/project_sync_worker_spec.rb
+44
-3
No files found.
ee/app/workers/geo/project_sync_worker.rb
View file @
6829b846
...
...
@@ -2,6 +2,7 @@ module Geo
class
ProjectSyncWorker
include
ApplicationWorker
include
GeoQueue
include
Gitlab
::
Geo
::
LogHelpers
sidekiq_options
retry:
3
,
dead:
false
...
...
@@ -16,11 +17,11 @@ module Geo
project
=
registry
.
project
if
project
.
nil?
Gitlab
::
Geo
::
Logger
.
error
(
class:
self
.
class
.
name
,
message:
"Couldn't find project, skipping syncing"
,
project_id:
project_id
)
log_error
(
"Couldn't find project, skipping syncing"
,
project_id:
project_id
)
return
end
unflag_disabled_wiki
(
registry
)
mark_disabled_wiki_as_synced
(
registry
)
Geo
::
RepositorySyncService
.
new
(
project
).
execute
if
registry
.
repository_sync_due?
(
scheduled_time
)
Geo
::
WikiSyncService
.
new
(
project
).
execute
if
registry
.
wiki_sync_due?
(
scheduled_time
)
...
...
@@ -28,10 +29,21 @@ module Geo
private
def
unflag_disabled_wiki
(
registry
)
return
unless
registry
.
resync_wiki
?
def
mark_disabled_wiki_as_synced
(
registry
)
return
if
registry
.
project
.
wiki_enabled
?
registry
.
update!
(
resync_wiki:
false
)
unless
registry
.
project
.
wiki_enabled?
registry
.
last_wiki_sync_failure
=
nil
registry
.
last_wiki_synced_at
=
DateTime
.
now
registry
.
last_wiki_successful_sync_at
=
DateTime
.
now
registry
.
resync_wiki
=
false
registry
.
wiki_retry_count
=
nil
registry
.
wiki_retry_at
=
nil
registry
.
force_to_redownload_wiki
=
false
if
registry
.
changed?
success
=
registry
.
save
log_info
(
"
#{
success
?
'Successfully marked'
:
'Failed to mark'
}
disabled wiki as synced"
,
registry_id:
registry
.
id
,
project_id:
registry
.
project_id
)
end
end
end
end
ee/spec/workers/geo/project_sync_worker_spec.rb
View file @
6829b846
...
...
@@ -107,19 +107,60 @@ RSpec.describe Geo::ProjectSyncWorker do
before
do
project
.
update!
(
wiki_enabled:
false
)
subject
.
perform
(
project
.
id
,
Time
.
now
)
end
it
'syncs the project repository'
do
subject
.
perform
(
project
.
id
,
Time
.
now
)
expect
(
repository_sync_service
).
to
have_received
(
:execute
)
end
it
'does not sync the project wiki'
do
subject
.
perform
(
project
.
id
,
Time
.
now
)
expect
(
wiki_sync_service
).
not_to
have_received
(
:execute
)
end
it
'unflags wiki for sync, to remove it from Geo wiki queries'
do
expect
(
registry
.
reload
.
resync_wiki
).
to
be_falsey
context
'when the wiki has failed to sync before'
do
let!
(
:registry
)
{
create
(
:geo_project_registry
,
:wiki_sync_failed
,
project:
project
)
}
it
'marks the wiki as synced, to remove it from failed Geo wiki queries'
do
subject
.
perform
(
project
.
id
,
Time
.
now
)
expect
(
registry
.
reload
.
resync_wiki
).
to
be_falsey
expect
(
registry
.
reload
.
last_wiki_sync_failure
).
to
be_nil
expect
(
registry
.
reload
.
last_wiki_synced_at
).
to
be_present
expect
(
registry
.
reload
.
last_wiki_successful_sync_at
).
to
be_present
expect
(
registry
.
reload
.
wiki_retry_count
).
to
be_nil
expect
(
registry
.
reload
.
wiki_retry_at
).
to
be_nil
expect
(
registry
.
reload
.
force_to_redownload_wiki
).
to
be_falsey
end
it
'logs that the wiki was marked as not needing a sync'
do
expect
(
subject
).
to
receive
(
:log_info
).
with
(
"Successfully marked disabled wiki as synced"
,
registry_id:
registry
.
id
,
project_id:
registry
.
project_id
)
subject
.
perform
(
project
.
id
,
Time
.
now
)
end
end
context
'when the wiki has never been synced before'
do
it
'marks the wiki as synced, to remove it from out-of-sync Geo wiki queries'
do
subject
.
perform
(
project
.
id
,
Time
.
now
)
expect
(
registry
.
reload
.
resync_wiki
).
to
be_falsey
expect
(
registry
.
reload
.
last_wiki_sync_failure
).
to
be_nil
expect
(
registry
.
reload
.
last_wiki_synced_at
).
to
be_present
expect
(
registry
.
reload
.
last_wiki_successful_sync_at
).
to
be_present
expect
(
registry
.
reload
.
wiki_retry_count
).
to
be_nil
expect
(
registry
.
reload
.
wiki_retry_at
).
to
be_nil
expect
(
registry
.
reload
.
force_to_redownload_wiki
).
to
be_falsey
end
it
'logs that the wiki was marked as not needing a sync'
do
expect
(
subject
).
to
receive
(
:log_info
).
with
(
"Successfully marked disabled wiki as synced"
,
registry_id:
registry
.
id
,
project_id:
registry
.
project_id
)
subject
.
perform
(
project
.
id
,
Time
.
now
)
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