Commit 75e52596 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch '300624-don-t-move-pages-on-disk-if-feature-flag-is-disabled' into 'master'

Don't move pages on disk if feature flag is disabled

See merge request gitlab-org/gitlab!53363
parents 9de6e57f 74dd4692
...@@ -9,7 +9,7 @@ class PagesTransferWorker # rubocop:disable Scalability/IdempotentWorker ...@@ -9,7 +9,7 @@ class PagesTransferWorker # rubocop:disable Scalability/IdempotentWorker
loggable_arguments 0, 1 loggable_arguments 0, 1
def perform(method, args) def perform(method, args)
return unless Gitlab::PagesTransfer::Async::METHODS.include?(method) return unless Gitlab::PagesTransfer::METHODS.include?(method)
result = Gitlab::PagesTransfer.new.public_send(method, *args) # rubocop:disable GitlabSecurity/PublicSend result = Gitlab::PagesTransfer.new.public_send(method, *args) # rubocop:disable GitlabSecurity/PublicSend
......
...@@ -7,16 +7,26 @@ ...@@ -7,16 +7,26 @@
# #
module Gitlab module Gitlab
class PagesTransfer < ProjectTransfer class PagesTransfer < ProjectTransfer
class Async METHODS = %w[move_namespace move_project rename_project rename_namespace].freeze
METHODS = %w[move_namespace move_project rename_project rename_namespace].freeze
class Async
METHODS.each do |meth| METHODS.each do |meth|
define_method meth do |*args| define_method meth do |*args|
next unless Feature.enabled?(:pages_update_legacy_storage, default_enabled: true)
PagesTransferWorker.perform_async(meth, args) PagesTransferWorker.perform_async(meth, args)
end end
end end
end end
METHODS.each do |meth|
define_method meth do |*args|
next unless Feature.enabled?(:pages_update_legacy_storage, default_enabled: true)
super(*args)
end
end
def async def async
@async ||= Async.new @async ||= Async.new
end end
......
...@@ -8,13 +8,24 @@ RSpec.describe Gitlab::PagesTransfer do ...@@ -8,13 +8,24 @@ RSpec.describe Gitlab::PagesTransfer do
context 'when receiving an allowed method' do context 'when receiving an allowed method' do
it 'schedules a PagesTransferWorker', :aggregate_failures do it 'schedules a PagesTransferWorker', :aggregate_failures do
described_class::Async::METHODS.each do |meth| described_class::METHODS.each do |meth|
expect(PagesTransferWorker) expect(PagesTransferWorker)
.to receive(:perform_async).with(meth, %w[foo bar]) .to receive(:perform_async).with(meth, %w[foo bar])
async.public_send(meth, 'foo', 'bar') async.public_send(meth, 'foo', 'bar')
end end
end end
it 'does nothing if legacy storage is disabled' do
stub_feature_flags(pages_update_legacy_storage: false)
described_class::METHODS.each do |meth|
expect(PagesTransferWorker)
.not_to receive(:perform_async)
async.public_send(meth, 'foo', 'bar')
end
end
end end
context 'when receiving a private method' do context 'when receiving a private method' do
...@@ -59,6 +70,15 @@ RSpec.describe Gitlab::PagesTransfer do ...@@ -59,6 +70,15 @@ RSpec.describe Gitlab::PagesTransfer do
expect(subject.public_send(meth, *args)).to be(false) expect(subject.public_send(meth, *args)).to be(false)
end end
it 'does nothing if legacy storage is disabled' do
stub_feature_flags(pages_update_legacy_storage: false)
subject.public_send(meth, *args)
expect(File.exist?(config_path_before)).to be(true)
expect(File.exist?(config_path_after)).to be(false)
end
end end
describe '#move_namespace' do describe '#move_namespace' do
......
...@@ -4,7 +4,7 @@ require 'spec_helper' ...@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe PagesTransferWorker do RSpec.describe PagesTransferWorker do
describe '#perform' do describe '#perform' do
Gitlab::PagesTransfer::Async::METHODS.each do |meth| Gitlab::PagesTransfer::METHODS.each do |meth|
context "when method is #{meth}" do context "when method is #{meth}" do
let(:args) { [1, 2, 3] } let(:args) { [1, 2, 3] }
......
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