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
30c34480
Commit
30c34480
authored
Sep 20, 2017
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only run Geo backfill for projects on healthy shards
parent
93044dec
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
1 deletion
+48
-1
app/workers/geo/repository_sync_worker.rb
app/workers/geo/repository_sync_worker.rb
+21
-1
spec/workers/geo/repository_sync_worker_spec.rb
spec/workers/geo/repository_sync_worker_spec.rb
+27
-0
No files found.
app/workers/geo/repository_sync_worker.rb
View file @
30c34480
...
@@ -22,7 +22,7 @@ module Geo
...
@@ -22,7 +22,7 @@ module Geo
end
end
def
find_project_ids_not_synced
def
find_project_ids_not_synced
current_node
.
unsynced_projects
healthy_shards_restriction
(
current_node
.
unsynced_projects
)
.
reorder
(
last_repository_updated_at: :desc
)
.
reorder
(
last_repository_updated_at: :desc
)
.
limit
(
db_retrieve_batch_size
)
.
limit
(
db_retrieve_batch_size
)
.
pluck
(
:id
)
.
pluck
(
:id
)
...
@@ -35,5 +35,25 @@ module Geo
...
@@ -35,5 +35,25 @@ module Geo
.
limit
(
db_retrieve_batch_size
)
.
limit
(
db_retrieve_batch_size
)
.
pluck
(
:project_id
)
.
pluck
(
:project_id
)
end
end
def
healthy_shards_restriction
(
relation
)
configured
=
Gitlab
.
config
.
repositories
.
storages
.
keys
referenced
=
Project
.
distinct
(
:repository_storage
).
pluck
(
:repository_storage
)
healthy
=
healthy_shards
known
=
configured
|
referenced
return
relation
if
(
known
-
healthy
).
empty?
relation
.
where
(
repository_storage:
healthy
)
end
def
healthy_shards
Gitlab
::
HealthChecks
::
FsShardsCheck
.
readiness
.
select
(
&
:success
)
.
map
{
|
check
|
check
.
labels
[
:shard
]
}
.
compact
.
uniq
end
end
end
end
end
spec/workers/geo/repository_sync_worker_spec.rb
View file @
30c34480
...
@@ -116,5 +116,32 @@ describe Geo::RepositorySyncWorker, :postgresql do
...
@@ -116,5 +116,32 @@ describe Geo::RepositorySyncWorker, :postgresql do
end
end
end
end
end
end
context
'unhealthy shards'
do
it
'skips backfill for repositories on unhealthy shards'
do
unhealthy
=
create
(
:project
,
group:
synced_group
,
repository_storage:
'broken'
)
# Make the shard unhealthy
FileUtils
.
rm_rf
(
unhealthy
.
repository_storage_path
)
expect
(
Geo
::
ProjectSyncWorker
).
to
receive
(
:perform_async
).
with
(
project_in_synced_group
.
id
,
anything
)
expect
(
Geo
::
ProjectSyncWorker
).
not_to
receive
(
:perform_async
).
with
(
unhealthy
.
id
,
anything
)
Sidekiq
::
Testing
.
inline!
{
subject
.
perform
}
end
it
'skips backfill for projects on missing shards'
do
missing
=
create
(
:project
,
group:
synced_group
)
missing
.
update_column
(
:repository_storage
,
'unknown'
)
# hide the 'broken' storage for this spec
stub_storage_settings
({})
expect
(
Geo
::
ProjectSyncWorker
).
to
receive
(
:perform_async
).
with
(
project_in_synced_group
.
id
,
anything
)
expect
(
Geo
::
ProjectSyncWorker
).
not_to
receive
(
:perform_async
).
with
(
missing
.
id
,
anything
)
Sidekiq
::
Testing
.
inline!
{
subject
.
perform
}
end
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