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
ad52783d
Commit
ad52783d
authored
Jan 10, 2020
by
Valery Sizov
Committed by
Mayra Cabrera
Jan 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make BackgroundMigrationWorker backward compatible
parent
36adf190
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
0 deletions
+30
-0
changelogs/unreleased/backward-compatibility-for-background-migrations.yml
...ased/backward-compatibility-for-background-migrations.yml
+5
-0
lib/gitlab/background_migration.rb
lib/gitlab/background_migration.rb
+14
-0
spec/lib/gitlab/background_migration_spec.rb
spec/lib/gitlab/background_migration_spec.rb
+11
-0
No files found.
changelogs/unreleased/backward-compatibility-for-background-migrations.yml
0 → 100644
View file @
ad52783d
---
title
:
Make BackgroundMigrationWorker backward compatible
merge_request
:
22271
author
:
type
:
fixed
lib/gitlab/background_migration.rb
View file @
ad52783d
...
@@ -78,6 +78,20 @@ module Gitlab
...
@@ -78,6 +78,20 @@ module Gitlab
end
end
def
self
.
migration_class_for
(
class_name
)
def
self
.
migration_class_for
(
class_name
)
# We don't pass class name with Gitlab::BackgroundMigration:: prefix anymore
# but some jobs could be already spawned so we need to have some backward compatibility period.
# Can be removed since 13.x
full_class_name_prefix_regexp
=
/\A(::)?Gitlab::BackgroundMigration::/
if
class_name
.
match
(
full_class_name_prefix_regexp
)
Gitlab
::
ErrorTracking
.
track_and_raise_for_dev_exception
(
StandardError
.
new
(
"Full class name is used"
),
class_name:
class_name
)
class_name
=
class_name
.
sub
(
full_class_name_prefix_regexp
,
''
)
end
const_get
(
class_name
,
false
)
const_get
(
class_name
,
false
)
end
end
...
...
spec/lib/gitlab/background_migration_spec.rb
View file @
ad52783d
...
@@ -152,6 +152,17 @@ describe Gitlab::BackgroundMigration do
...
@@ -152,6 +152,17 @@ describe Gitlab::BackgroundMigration do
described_class
.
perform
(
'Foo'
,
[
10
,
20
])
described_class
.
perform
(
'Foo'
,
[
10
,
20
])
end
end
context
'backward compatibility'
do
it
'performs a background migration for fully-qualified job classes'
do
expect
(
migration
).
to
receive
(
:perform
).
with
(
10
,
20
).
once
expect
(
Gitlab
::
ErrorTracking
)
.
to
receive
(
:track_and_raise_for_dev_exception
)
.
with
(
instance_of
(
StandardError
),
hash_including
(
:class_name
))
described_class
.
perform
(
'Gitlab::BackgroundMigration::Foo'
,
[
10
,
20
])
end
end
end
end
describe
'.exists?'
do
describe
'.exists?'
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