Commit 38277618 authored by Vladimir Shushlin's avatar Vladimir Shushlin

Stop migrating pages metadata on API requests

In 14.0 we disable serving from legacy storage and only allow serving
from deployments, so migrated metadata doesn't work on it's own.

Also this metadata is migrated in background and is created during
project creation.
parent 4696e416
......@@ -436,12 +436,6 @@ class Namespace < ApplicationRecord
end
def all_projects_with_pages
if all_projects.pages_metadata_not_migrated.exists?
Gitlab::BackgroundMigration::MigratePagesMetadata.new.perform_on_relation(
all_projects.pages_metadata_not_migrated
)
end
all_projects.with_pages_deployed
end
......
......@@ -225,16 +225,6 @@ class PagesDomain < ApplicationRecord
def pages_deployed?
return false unless project
# TODO: remove once `pages_metadatum` is migrated
# https://gitlab.com/gitlab-org/gitlab/issues/33106
unless project.pages_metadatum
Gitlab::BackgroundMigration::MigratePagesMetadata
.new
.perform_on_relation(Project.where(id: project_id))
project.reset
end
project.pages_metadatum&.deployed?
end
......
......@@ -1368,38 +1368,16 @@ RSpec.describe Namespace do
describe '#pages_virtual_domain' do
let(:project) { create(:project, namespace: namespace) }
context 'when there are pages deployed for the project' do
context 'but pages metadata is not migrated' do
before do
generic_commit_status = create(:generic_commit_status, :success, stage: 'deploy', name: 'pages:deploy')
generic_commit_status.update!(project: project)
project.pages_metadatum.destroy!
end
it 'migrates pages metadata and returns the virual domain' do
virtual_domain = namespace.pages_virtual_domain
expect(project.reload.pages_metadatum.deployed).to eq(true)
expect(virtual_domain).to be_an_instance_of(Pages::VirtualDomain)
expect(virtual_domain.lookup_paths).not_to be_empty
end
end
context 'and pages metadata is migrated' do
before do
it 'returns the virual domain' do
project.mark_pages_as_deployed
end
project.update_pages_deployment!(create(:pages_deployment, project: project))
it 'returns the virual domain' do
virtual_domain = namespace.pages_virtual_domain
expect(virtual_domain).to be_an_instance_of(Pages::VirtualDomain)
expect(virtual_domain.lookup_paths).not_to be_empty
end
end
end
end
describe '#any_project_with_pages_deployed?' do
it 'returns true if any project nested under the group has pages deployed' do
......
......@@ -655,25 +655,16 @@ RSpec.describe PagesDomain do
end
end
context 'when there are pages deployed for the project' do
before do
generic_commit_status = create(:generic_commit_status, :success, stage: 'deploy', name: 'pages:deploy')
generic_commit_status.update!(project: project)
project.pages_metadatum.destroy!
project.reload
end
it 'returns the virual domain when there are pages deployed for the project' do
project.mark_pages_as_deployed
project.update_pages_deployment!(create(:pages_deployment, project: project))
it 'returns the virual domain' do
expect(Pages::VirtualDomain).to receive(:new).with([project], domain: pages_domain).and_call_original
expect(pages_domain.pages_virtual_domain).to be_an_instance_of(Pages::VirtualDomain)
end
virtual_domain = pages_domain.pages_virtual_domain
it 'migrates project pages metadata' do
expect { pages_domain.pages_virtual_domain }.to change {
project.reload.pages_metadatum&.deployed
}.from(nil).to(true)
end
expect(virtual_domain).to be_an_instance_of(Pages::VirtualDomain)
expect(virtual_domain.lookup_paths).not_to be_empty
end
end
......
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