Commit fb139b00 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'backward-compatibility-for-background-migrations' into 'master'

Make BackgroundMigrationWorker backward compatible

See merge request gitlab-org/gitlab!22271
parents 36adf190 ad52783d
---
title: Make BackgroundMigrationWorker backward compatible
merge_request: 22271
author:
type: fixed
......@@ -78,6 +78,20 @@ module Gitlab
end
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)
end
......
......@@ -152,6 +152,17 @@ describe Gitlab::BackgroundMigration do
described_class.perform('Foo', [10, 20])
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
describe '.exists?' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment