Commit 9c76d457 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'vshushlin-dont-migrate-pages-metadata-in-flyight' into 'master'

Stop migrating pages metadata on API requests

See merge request gitlab-org/gitlab!62570
parents dca443fc 38277618
...@@ -437,12 +437,6 @@ class Namespace < ApplicationRecord ...@@ -437,12 +437,6 @@ class Namespace < ApplicationRecord
end end
def all_projects_with_pages 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 all_projects.with_pages_deployed
end end
......
...@@ -227,16 +227,6 @@ class PagesDomain < ApplicationRecord ...@@ -227,16 +227,6 @@ class PagesDomain < ApplicationRecord
def pages_deployed? def pages_deployed?
return false unless project 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? project.pages_metadatum&.deployed?
end end
......
...@@ -1387,38 +1387,16 @@ RSpec.describe Namespace do ...@@ -1387,38 +1387,16 @@ RSpec.describe Namespace do
describe '#pages_virtual_domain' do describe '#pages_virtual_domain' do
let(:project) { create(:project, namespace: namespace) } let(:project) { create(:project, namespace: namespace) }
context 'when there are pages deployed for the project' do it 'returns the virual domain' 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
project.mark_pages_as_deployed 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 virtual_domain = namespace.pages_virtual_domain
expect(virtual_domain).to be_an_instance_of(Pages::VirtualDomain) expect(virtual_domain).to be_an_instance_of(Pages::VirtualDomain)
expect(virtual_domain.lookup_paths).not_to be_empty expect(virtual_domain.lookup_paths).not_to be_empty
end end
end end
end
end
describe '#any_project_with_pages_deployed?' do describe '#any_project_with_pages_deployed?' do
it 'returns true if any project nested under the group has pages deployed' do it 'returns true if any project nested under the group has pages deployed' do
......
...@@ -664,25 +664,16 @@ RSpec.describe PagesDomain do ...@@ -664,25 +664,16 @@ RSpec.describe PagesDomain do
end end
end end
context 'when there are pages deployed for the project' do it 'returns the virual domain when there are pages deployed for the project' do
before do project.mark_pages_as_deployed
generic_commit_status = create(:generic_commit_status, :success, stage: 'deploy', name: 'pages:deploy') project.update_pages_deployment!(create(:pages_deployment, project: project))
generic_commit_status.update!(project: project)
project.pages_metadatum.destroy!
project.reload
end
it 'returns the virual domain' do
expect(Pages::VirtualDomain).to receive(:new).with([project], domain: pages_domain).and_call_original 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) virtual_domain = pages_domain.pages_virtual_domain
end
it 'migrates project pages metadata' do expect(virtual_domain).to be_an_instance_of(Pages::VirtualDomain)
expect { pages_domain.pages_virtual_domain }.to change { expect(virtual_domain.lookup_paths).not_to be_empty
project.reload.pages_metadatum&.deployed
}.from(nil).to(true)
end
end end
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