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
fd9d7438
Commit
fd9d7438
authored
Jan 29, 2018
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Skip backfill workers for shards that are disabled in selective sync
parent
fe547a9f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
8 deletions
+32
-8
ee/app/workers/geo/repository_sync_worker.rb
ee/app/workers/geo/repository_sync_worker.rb
+7
-1
spec/ee/spec/workers/geo/repository_sync_worker_spec.rb
spec/ee/spec/workers/geo/repository_sync_worker_spec.rb
+25
-7
No files found.
ee/app/workers/geo/repository_sync_worker.rb
View file @
fd9d7438
...
...
@@ -12,7 +12,7 @@ module Geo
return
unless
Gitlab
::
Geo
.
geo_database_configured?
return
unless
Gitlab
::
Geo
.
secondary?
shards
=
healthy_shards
shards
=
selective_sync_filter
(
healthy_shards
)
Gitlab
::
Geo
::
ShardHealthCache
.
update
(
shards
)
...
...
@@ -32,5 +32,11 @@ module Geo
.
compact
.
uniq
end
def
selective_sync_filter
(
shards
)
return
shards
unless
::
Gitlab
::
Geo
.
current_node
&
.
selective_sync_by_shards?
shards
&
::
Gitlab
::
Geo
.
current_node
.
selective_sync_shards
end
end
end
spec/ee/spec/workers/geo/repository_sync_worker_spec.rb
View file @
fd9d7438
...
...
@@ -9,6 +9,8 @@ describe Geo::RepositorySyncWorker, :geo, :clean_gitlab_redis_cache do
let!
(
:project_in_synced_group
)
{
create
(
:project
,
group:
synced_group
)
}
let!
(
:unsynced_project
)
{
create
(
:project
)
}
let
(
:healthy_shard
)
{
project_in_synced_group
.
repository
.
storage
}
subject
{
described_class
.
new
}
before
do
...
...
@@ -32,6 +34,21 @@ describe Geo::RepositorySyncWorker, :geo, :clean_gitlab_redis_cache do
Sidekiq
::
Testing
.
inline!
{
subject
.
perform
}
end
it
'skips backfill for projects on shards excluded by selective sync'
do
secondary
.
update!
(
selective_sync_type:
'shards'
,
selective_sync_shards:
[
healthy_shard
])
# Report both shards as healthy
expect
(
Gitlab
::
HealthChecks
::
FsShardsCheck
).
to
receive
(
:readiness
)
.
and_return
([
result
(
true
,
healthy_shard
),
result
(
true
,
'broken'
)])
expect
(
Gitlab
::
HealthChecks
::
GitalyCheck
).
to
receive
(
:readiness
)
.
and_return
([
result
(
true
,
healthy_shard
),
result
(
true
,
'broken'
)])
expect
(
Geo
::
RepositoryShardSyncWorker
).
to
receive
(
:perform_async
).
with
(
'default'
)
expect
(
Geo
::
RepositoryShardSyncWorker
).
not_to
receive
(
:perform_async
).
with
(
'broken'
)
Sidekiq
::
Testing
.
inline!
{
subject
.
perform
}
end
it
'skips backfill for projects on missing shards'
do
missing_not_synced
=
create
(
:project
,
group:
synced_group
)
missing_not_synced
.
update_column
(
:repository_storage
,
'unknown'
)
...
...
@@ -52,17 +69,14 @@ describe Geo::RepositorySyncWorker, :geo, :clean_gitlab_redis_cache do
it
'skips backfill for projects with downed Gitaly server'
do
create
(
:project
,
group:
synced_group
,
repository_storage:
'broken'
)
unhealthy_dirty
=
create
(
:project
,
group:
synced_group
,
repository_storage:
'broken'
)
healthy_shard
=
project_in_synced_group
.
repository
.
storage
create
(
:geo_project_registry
,
:synced
,
:repository_dirty
,
project:
unhealthy_dirty
)
# Report only one healthy shard
allow
(
Gitlab
::
HealthChecks
::
FsShardsCheck
).
to
receive
(
:readiness
).
and_return
(
[
Gitlab
::
HealthChecks
::
Result
.
new
(
true
,
nil
,
{
shard:
healthy_shard
}),
Gitlab
::
HealthChecks
::
Result
.
new
(
true
,
nil
,
{
shard:
'broken'
})])
allow
(
Gitlab
::
HealthChecks
::
GitalyCheck
).
to
receive
(
:readiness
).
and_return
(
[
Gitlab
::
HealthChecks
::
Result
.
new
(
true
,
nil
,
{
shard:
healthy_shard
}),
Gitlab
::
HealthChecks
::
Result
.
new
(
false
,
nil
,
{
shard:
'broken'
})])
expect
(
Gitlab
::
HealthChecks
::
FsShardsCheck
).
to
receive
(
:readiness
)
.
and_return
([
result
(
true
,
healthy_shard
),
result
(
true
,
'broken'
)])
expect
(
Gitlab
::
HealthChecks
::
GitalyCheck
).
to
receive
(
:readiness
)
.
and_return
([
result
(
true
,
healthy_shard
),
result
(
false
,
'broken'
)])
expect
(
Geo
::
RepositoryShardSyncWorker
).
to
receive
(
:perform_async
).
with
(
healthy_shard
)
expect
(
Geo
::
RepositoryShardSyncWorker
).
not_to
receive
(
:perform_async
).
with
(
'broken'
)
...
...
@@ -71,4 +85,8 @@ describe Geo::RepositorySyncWorker, :geo, :clean_gitlab_redis_cache do
end
end
end
def
result
(
success
,
shard
)
Gitlab
::
HealthChecks
::
Result
.
new
(
success
,
nil
,
{
shard:
shard
})
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