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
00adcb32
Commit
00adcb32
authored
Jul 31, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add group restrictions when performing a full scan on Geo::LogCursor
parent
6a8fe020
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
5 deletions
+32
-5
lib/gitlab/geo/log_cursor/daemon.rb
lib/gitlab/geo/log_cursor/daemon.rb
+11
-1
spec/lib/gitlab/geo/log_cursor/daemon_spec.rb
spec/lib/gitlab/geo/log_cursor/daemon_spec.rb
+21
-4
No files found.
lib/gitlab/geo/log_cursor/daemon.rb
View file @
00adcb32
...
...
@@ -38,7 +38,17 @@ module Gitlab
# Projects without corresponding ProjectRegistry in the DR database
# See: https://robots.thoughtbot.com/postgres-foreign-data-wrapper (requires PG 9.6)
$stdout
.
print
'Searching for non replicated projects...'
Project
.
select
(
:id
).
find_in_batches
(
batch_size:
BATCH_SIZE
)
do
|
batch
|
restricted_project_ids
=
Gitlab
::
Geo
.
current_node
.
project_ids
relation
=
if
restricted_project_ids
Project
.
where
(
id:
restricted_project_ids
)
else
Project
.
all
end
relation
.
select
(
:id
).
find_in_batches
(
batch_size:
BATCH_SIZE
)
do
|
batch
|
$stdout
.
print
'.'
project_ids
=
batch
.
map
(
&
:
id
)
...
...
spec/lib/gitlab/geo/log_cursor/daemon_spec.rb
View file @
00adcb32
...
...
@@ -83,8 +83,9 @@ describe Gitlab::Geo::LogCursor::Daemon do
context
'when node have group restrictions'
do
let
(
:geo_node
)
{
create
(
:geo_node
,
:current
)
}
let
(
:group
)
{
create
(
:group
)
}
let
(
:project
)
{
create
(
:empty_project
,
group:
group
)
}
let
(
:group_1
)
{
create
(
:group
)
}
let
(
:group_2
)
{
create
(
:group
)
}
let
(
:project
)
{
create
(
:empty_project
,
group:
group_1
)
}
let
(
:repository_updated_event
)
{
create
(
:geo_repository_updated_event
,
project:
project
)
}
let
(
:event_log
)
{
create
(
:geo_event_log
,
repository_updated_event:
repository_updated_event
)
}
let!
(
:event_log_state
)
{
create
(
:geo_event_log_state
,
event_id:
event_log
.
id
-
1
)
}
...
...
@@ -94,16 +95,32 @@ describe Gitlab::Geo::LogCursor::Daemon do
end
it
'replays events for projects that belong to selected groups to replicate'
do
geo_node
.
update_attribute
(
:groups
,
[
group
])
geo_node
.
update_attribute
(
:groups
,
[
group
_1
])
expect
{
subject
.
run!
}.
to
change
(
Geo
::
ProjectRegistry
,
:count
).
by
(
1
)
end
it
'does not replay events for projects that do not belong to selected groups to replicate'
do
geo_node
.
update_attribute
(
:groups
,
[
create
(
:group
)
])
geo_node
.
update_attribute
(
:groups
,
[
group_2
])
expect
{
subject
.
run!
}.
not_to
change
(
Geo
::
ProjectRegistry
,
:count
)
end
context
'when performing a full scan'
do
subject
{
described_class
.
new
(
full_scan:
true
)
}
it
'creates registries for missing projects that belong to selected groups'
do
geo_node
.
update_attribute
(
:groups
,
[
group_1
])
expect
{
subject
.
run!
}.
to
change
(
Geo
::
ProjectRegistry
,
:count
).
by
(
1
)
end
it
'does not create registries for missing projects that do not belong to selected groups'
do
geo_node
.
update_attribute
(
:groups
,
[
group_2
])
expect
{
subject
.
run!
}.
not_to
change
(
Geo
::
ProjectRegistry
,
:count
)
end
end
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