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
e84bb5fb
Commit
e84bb5fb
authored
Nov 18, 2016
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor Geo Backfill Repository's code
parent
5ff87dc8
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
11 additions
and
10 deletions
+11
-10
app/controllers/admin/geo_nodes_controller.rb
app/controllers/admin/geo_nodes_controller.rb
+5
-4
app/models/geo_node.rb
app/models/geo_node.rb
+2
-2
app/services/geo/schedule_backfill_service.rb
app/services/geo/schedule_backfill_service.rb
+1
-1
app/workers/geo_repository_backfill_worker.rb
app/workers/geo_repository_backfill_worker.rb
+1
-1
spec/models/geo_node_spec.rb
spec/models/geo_node_spec.rb
+1
-1
spec/services/geo/schedule_backfill_service_spec.rb
spec/services/geo/schedule_backfill_service_spec.rb
+1
-1
No files found.
app/controllers/admin/geo_nodes_controller.rb
View file @
e84bb5fb
class
Admin::GeoNodesController
<
Admin
::
ApplicationController
before_action
:check_license
before_action
:load_node
,
except:
[
:index
,
:create
]
def
index
@nodes
=
GeoNode
.
all
...
...
@@ -18,15 +19,12 @@ class Admin::GeoNodesController < Admin::ApplicationController
end
def
destroy
@node
=
GeoNode
.
find
(
params
[
:id
])
@node
.
destroy
redirect_to
admin_geo_nodes_path
,
notice:
'Node was successfully removed.'
end
def
repair
@node
=
GeoNode
.
find
(
params
[
:id
])
if
@node
.
primary?
||
!
@node
.
missing_oauth_application?
flash
[
:notice
]
=
"This node doesn't need to be repaired."
elsif
@node
.
save
...
...
@@ -39,7 +37,6 @@ class Admin::GeoNodesController < Admin::ApplicationController
end
def
backfill_repositories
@node
=
GeoNode
.
find
(
params
[
:id
])
if
@node
.
primary?
redirect_to
admin_geo_nodes_path
,
notice:
'This is the primary node. Please run this action with a secondary node.'
else
...
...
@@ -61,4 +58,8 @@ class Admin::GeoNodesController < Admin::ApplicationController
redirect_to
admin_license_path
end
end
def
load_node
@node
=
GeoNode
.
find
(
params
[
:id
])
end
end
app/models/geo_node.rb
View file @
e84bb5fb
...
...
@@ -66,8 +66,8 @@ class GeoNode < ActiveRecord::Base
end
def
backfill_repositories
if
Gitlab
::
Geo
.
enabled?
GeoScheduleBackfillWorker
.
perform_async
(
id
)
unless
primary?
if
Gitlab
::
Geo
.
enabled?
&&
!
primary?
GeoScheduleBackfillWorker
.
perform_async
(
id
)
end
end
...
...
app/services/geo/schedule_backfill_service.rb
View file @
e84bb5fb
...
...
@@ -10,7 +10,7 @@ module Geo
return
if
geo_node_id
.
nil?
Project
.
find_each
(
batch_size:
100
)
do
|
project
|
GeoBackfillWorker
.
perform_async
(
geo_node_id
,
project
.
id
)
if
project
.
valid_repo?
Geo
Repository
BackfillWorker
.
perform_async
(
geo_node_id
,
project
.
id
)
if
project
.
valid_repo?
end
end
end
...
...
app/workers/geo_backfill_worker.rb
→
app/workers/geo_
repository_
backfill_worker.rb
View file @
e84bb5fb
class
GeoBackfillWorker
class
Geo
Repository
BackfillWorker
include
Sidekiq
::
Worker
include
::
GeoDynamicBackoff
include
GeoQueue
...
...
spec/models/geo_node_spec.rb
View file @
e84bb5fb
...
...
@@ -245,7 +245,7 @@ describe GeoNode, type: :model do
node
.
backfill_repositories
expect
{
GeoScheduleBackfillWorker
.
drain
}.
to
change
(
GeoBackfillWorker
.
jobs
,
:size
).
by
(
2
)
expect
{
GeoScheduleBackfillWorker
.
drain
}.
to
change
(
Geo
Repository
BackfillWorker
.
jobs
,
:size
).
by
(
2
)
end
end
end
...
...
spec/services/geo/schedule_backfill_service_spec.rb
View file @
e84bb5fb
...
...
@@ -13,7 +13,7 @@ describe Geo::ScheduleBackfillService, services: true do
create
(
:project
)
end
expect
{
subject
.
execute
}.
to
change
(
GeoBackfillWorker
.
jobs
,
:size
).
by
(
2
)
expect
{
subject
.
execute
}.
to
change
(
Geo
Repository
BackfillWorker
.
jobs
,
:size
).
by
(
2
)
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