Commit 4df94e2d authored by Vladimir Shushlin's avatar Vladimir Shushlin Committed by Kamil Trzciński

Remove serving pages from artifacts archives

parent 977fb981
......@@ -2,6 +2,8 @@
module Pages
class LookupPath
include Gitlab::Utils::StrongMemoize
def initialize(project, trim_prefix: nil, domain: nil)
@project = project
@domain = domain
......@@ -37,37 +39,28 @@ module Pages
attr_reader :project, :trim_prefix, :domain
def artifacts_archive
return unless Feature.enabled?(:pages_serve_from_artifacts_archive, project)
project.pages_metadatum.artifacts_archive
end
def deployment
return unless Feature.enabled?(:pages_serve_from_deployments, project)
strong_memoize(:deployment) do
next unless Feature.enabled?(:pages_serve_from_deployments, project)
project.pages_metadatum.pages_deployment
project.pages_metadatum.pages_deployment
end
end
def zip_source
source = deployment || artifacts_archive
return unless source&.file
return if source.file.file_storage? && !Feature.enabled?(:pages_serve_with_zip_file_protocol, project)
return unless deployment&.file
# artifacts archive doesn't support this
file_count = source.file_count if source.respond_to?(:file_count)
return if deployment.file.file_storage? && !Feature.enabled?(:pages_serve_with_zip_file_protocol, project)
global_id = ::Gitlab::GlobalId.build(source, id: source.id).to_s
global_id = ::Gitlab::GlobalId.build(deployment, id: deployment.id).to_s
{
type: 'zip',
path: source.file.url_or_file_path(expire_at: 1.day.from_now),
path: deployment.file.url_or_file_path(expire_at: 1.day.from_now),
global_id: global_id,
sha256: source.file_sha256,
file_size: source.size,
file_count: file_count
sha256: deployment.file_sha256,
file_size: deployment.size,
file_count: deployment.file_count
}
end
......
---
name: pages_serve_from_artifacts_archive
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/46320
rollout_issue_url:
group: group::release management
milestone: '13.4'
type: development
default_enabled: false
......@@ -9,7 +9,6 @@ RSpec.describe Pages::LookupPath do
before do
stub_pages_setting(access_control: true, external_https: ["1.1.1.1:443"])
stub_artifacts_object_storage
stub_pages_object_storage(::Pages::DeploymentUploader)
end
......@@ -117,64 +116,6 @@ RSpec.describe Pages::LookupPath do
include_examples 'uses disk storage'
end
end
context 'when artifact_id from build job is present in pages metadata' do
let(:artifacts_archive) { create(:ci_job_artifact, :zip, :remote_store, project: project) }
before do
project.mark_pages_as_deployed(artifacts_archive: artifacts_archive)
end
it 'uses artifacts object storage' do
Timecop.freeze do
expect(source).to(
eq({
type: 'zip',
path: artifacts_archive.file.url(expire_at: 1.day.from_now),
global_id: "gid://gitlab/Ci::JobArtifact/#{artifacts_archive.id}",
sha256: artifacts_archive.file_sha256,
file_size: artifacts_archive.size,
file_count: nil
})
)
end
end
context 'when artifact is not uploaded to object storage' do
let(:artifacts_archive) { create(:ci_job_artifact, :zip) }
it 'uses file protocol', :aggregate_failures do
Timecop.freeze do
expect(source).to(
eq({
type: 'zip',
path: 'file://' + artifacts_archive.file.path,
global_id: "gid://gitlab/Ci::JobArtifact/#{artifacts_archive.id}",
sha256: artifacts_archive.file_sha256,
file_size: artifacts_archive.size,
file_count: nil
})
)
end
end
context 'when pages_serve_with_zip_file_protocol feature flag is disabled' do
before do
stub_feature_flags(pages_serve_with_zip_file_protocol: false)
end
include_examples 'uses disk storage'
end
end
context 'when feature flag is disabled' do
before do
stub_feature_flags(pages_serve_from_artifacts_archive: 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