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
c34f6ea6
Commit
c34f6ea6
authored
Jan 30, 2019
by
Mark Chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Consume remaining MigrateApproverToApprovalRulesInBatch
Allow `steal` to handle dead jobs.
parent
dd26a9ad
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
4 deletions
+43
-4
lib/gitlab/background_migration.rb
lib/gitlab/background_migration.rb
+11
-4
spec/lib/gitlab/background_migration_spec.rb
spec/lib/gitlab/background_migration_spec.rb
+32
-0
No files found.
lib/gitlab/background_migration.rb
View file @
c34f6ea6
...
...
@@ -16,11 +16,18 @@ module Gitlab
# re-raises the exception.
#
# steal_class - The name of the class for which to steal jobs.
def
self
.
steal
(
steal_class
)
enqueued
=
Sidekiq
::
Queue
.
new
(
self
.
queue
)
scheduled
=
Sidekiq
::
ScheduledSet
.
new
def
self
.
steal
(
steal_class
,
retry_dead_jobs:
false
)
queues
=
[
Sidekiq
::
ScheduledSet
.
new
,
Sidekiq
::
Queue
.
new
(
self
.
queue
)
]
if
retry_dead_jobs
queues
<<
Sidekiq
::
RetrySet
.
new
queues
<<
Sidekiq
::
DeadSet
.
new
end
[
scheduled
,
enqueued
]
.
each
do
|
queue
|
queues
.
each
do
|
queue
|
queue
.
each
do
|
job
|
migration_class
,
migration_args
=
job
.
args
...
...
spec/lib/gitlab/background_migration_spec.rb
View file @
c34f6ea6
...
...
@@ -104,6 +104,38 @@ describe Gitlab::BackgroundMigration do
end
end
end
context
'when retry_dead_jobs is true'
,
:sidekiq
,
:redis
do
let
(
:retry_queue
)
do
[
double
(
args:
[
'Object'
,
[
3
]],
queue:
described_class
.
queue
,
delete:
true
)]
end
let
(
:dead_queue
)
do
[
double
(
args:
[
'Object'
,
[
4
]],
queue:
described_class
.
queue
,
delete:
true
)]
end
before
do
allow
(
Sidekiq
::
RetrySet
).
to
receive
(
:new
).
and_return
(
retry_queue
)
allow
(
Sidekiq
::
DeadSet
).
to
receive
(
:new
).
and_return
(
dead_queue
)
end
it
'steals from the dead and retry queue'
do
Sidekiq
::
Testing
.
disable!
do
expect
(
described_class
).
to
receive
(
:perform
)
.
with
(
'Object'
,
[
1
]).
ordered
expect
(
described_class
).
to
receive
(
:perform
)
.
with
(
'Object'
,
[
2
]).
ordered
expect
(
described_class
).
to
receive
(
:perform
)
.
with
(
'Object'
,
[
3
]).
ordered
expect
(
described_class
).
to
receive
(
:perform
)
.
with
(
'Object'
,
[
4
]).
ordered
BackgroundMigrationWorker
.
perform_async
(
'Object'
,
[
2
])
BackgroundMigrationWorker
.
perform_in
(
10
.
minutes
,
'Object'
,
[
1
])
described_class
.
steal
(
'Object'
,
retry_dead_jobs:
true
)
end
end
end
end
describe
'.perform'
do
...
...
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