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
54ec4cae
Commit
54ec4cae
authored
5 years ago
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Respects Geo secondary node max capacity per shard
parent
45115cd0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
16 deletions
+25
-16
ee/app/workers/geo/secondary/repository_backfill_worker.rb
ee/app/workers/geo/secondary/repository_backfill_worker.rb
+17
-12
ee/spec/workers/geo/secondary/repository_backfill_worker_spec.rb
.../workers/geo/secondary/repository_backfill_worker_spec.rb
+8
-4
No files found.
ee/app/workers/geo/secondary/repository_backfill_worker.rb
View file @
54ec4cae
...
...
@@ -31,17 +31,19 @@ module Geo
update_jobs_in_progress
# This will stream the results one by one
# until there are no more results to fetch.
result
=
connection
.
get_result
break
:complete
if
result
.
nil?
result
.
check
result
.
each
do
|
row
|
schedule_job
(
row
[
'id'
])
unless
over_capacity?
# This will stream the results one by one
# until there are no more results to fetch.
result
=
connection
.
get_result
break
:complete
if
result
.
nil?
result
.
check
result
.
each
do
|
row
|
schedule_job
(
row
[
'id'
])
end
else
sleep
(
1
)
end
sleep
(
1
)
if
over_capacity?
end
rescue
=>
error
reason
=
:error
...
...
@@ -93,12 +95,15 @@ module Geo
end
def
update_jobs_in_progress
status
=
Gitlab
::
SidekiqStatus
.
job_status
(
scheduled_job_ids
)
job_ids
=
scheduled_job_ids
return
if
job_ids
.
empty?
# SidekiqStatus returns an array of booleans: true if the job is still running, false otherwise.
# For each entry, first use `zip` to make { job_id: 123 } -> [ { job_id: 123 }, bool ]
# Next, filter out the jobs that have completed.
@scheduled_jobs
=
@scheduled_jobs
.
zip
(
status
).
map
{
|
(
job
,
running
)
|
job
if
running
}.
compact
@scheduled_jobs
=
Gitlab
::
SidekiqStatus
.
job_status
(
scheduled_job_ids
).
then
do
|
status
|
@scheduled_jobs
.
zip
(
status
).
map
{
|
(
job
,
running
)
|
job
if
running
}.
compact
end
end
def
scheduled_job_ids
...
...
This diff is collapsed.
Click to expand it.
ee/spec/workers/geo/secondary/repository_backfill_worker_spec.rb
View file @
54ec4cae
...
...
@@ -90,10 +90,14 @@ describe Geo::Secondary::RepositoryBackfillWorker, :geo, :geo_fdw, :clean_gitlab
it
'respects Geo secondary node max capacity per shard'
do
stub_healthy_shards
([
shard_name
,
'shard2'
,
'shard3'
,
'shard4'
,
'shard5'
])
allow
(
Geo
::
ProjectSyncWorker
).
to
receive
(
:perform_async
).
twice
.
and_return
(
'jid-123'
)
create_list
(
:project
,
2
)
expect
(
subject
).
to
receive
(
:sleep
).
twice
.
and_call_original
project_1
=
create
(
:project
)
project_2
=
create
(
:project
)
allow
(
Geo
::
ProjectSyncWorker
).
to
receive
(
:perform_async
).
with
(
project_1
.
id
,
anything
).
and_return
(
'jid-1'
)
allow
(
Geo
::
ProjectSyncWorker
).
to
receive
(
:perform_async
).
with
(
project_2
.
id
,
anything
).
and_return
(
'jid-2'
)
allow
(
Gitlab
::
SidekiqStatus
).
to
receive
(
:job_status
).
with
([
'jid-2'
]).
and_return
([
true
],
[
false
])
allow
(
Gitlab
::
SidekiqStatus
).
to
receive
(
:job_status
).
with
([
'jid-1'
]).
and_return
([
false
])
expect
(
subject
).
to
receive
(
:sleep
).
once
.
and_call_original
subject
.
perform
(
shard_name
)
end
...
...
This diff is collapsed.
Click to expand it.
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