Commit d04727dc authored by Vladimir Shushlin's avatar Vladimir Shushlin

Only serve migrated pages if feature flag is enabled

It will allow us to disable all migrated deployments
if something goes wrong, as well as to gradually rollout
the migration
parent 09c2a929
......@@ -5,6 +5,7 @@ module Pages
include Gitlab::Utils::StrongMemoize
LegacyStorageDisabledError = Class.new(::StandardError)
MIGRATED_FILE_NAME = "_migrated.zip"
def initialize(project, trim_prefix: nil, domain: nil)
@project = project
......@@ -54,6 +55,8 @@ module Pages
return if deployment.file.file_storage? && !Feature.enabled?(:pages_serve_with_zip_file_protocol, project)
return if deployment.file.filename == MIGRATED_FILE_NAME && !Feature.enabled?(:pages_serve_from_migrated_zip, project)
global_id = ::Gitlab::GlobalId.build(deployment, id: deployment.id).to_s
{
......
---
name: pages_serve_from_migrated_zip
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/52573
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/300021
milestone: '13.9'
type: development
group: group::release
default_enabled: false
......@@ -125,6 +125,44 @@ RSpec.describe Pages::LookupPath do
include_examples 'uses disk storage'
end
end
context 'when deployment were created during migration' do
before do
FileUtils.mkdir_p File.join(project.pages_path, "public")
File.open(File.join(project.pages_path, "public/index.html"), "w") do |f|
f.write("Hello!")
end
expect(::Pages::MigrateLegacyStorageToDeploymentService.new(project).execute[:status]).to eq(:success)
project.reload
end
let(:deployment) { project.pages_metadatum.pages_deployment }
it 'uses deployment from object storage' do
freeze_time do
expect(source).to(
eq({
type: 'zip',
path: deployment.file.url(expire_at: 1.day.from_now),
global_id: "gid://gitlab/PagesDeployment/#{deployment.id}",
sha256: deployment.file_sha256,
file_size: deployment.size,
file_count: deployment.file_count
})
)
end
end
context 'when pages_serve_from_migrated_zip feature flag is disabled' do
before do
stub_feature_flags(pages_serve_from_migrated_zip: false)
end
include_examples 'uses disk storage'
end
end
end
describe '#prefix' 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