Commit 2b9e609f authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch 'eb-return-filesize-authorize' into 'master'

Include max artifact size in authorize response

See merge request gitlab-org/gitlab!37632
parents a150f511 5ce80ffc
......@@ -178,10 +178,14 @@ module ObjectStorage
end
def workhorse_authorize(has_length:, maximum_size: nil)
{}.tap do |hash|
if self.object_store_enabled? && self.direct_upload_enabled?
{ RemoteObject: workhorse_remote_upload_options(has_length: has_length, maximum_size: maximum_size) }
hash[:RemoteObject] = workhorse_remote_upload_options(has_length: has_length, maximum_size: maximum_size)
else
{ TempPath: workhorse_local_upload_path }
hash[:TempPath] = workhorse_local_upload_path
end
hash[:MaximumSize] = maximum_size if maximum_size.present?
end
end
......
---
title: Include max artifact size in authorize response
merge_request: 37632
author:
type: added
......@@ -143,6 +143,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
expect(response.media_type).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE)
expect(json_response['TempPath']).to eq(JobArtifactUploader.workhorse_local_upload_path)
expect(json_response['RemoteObject']).to be_nil
expect(json_response['MaximumSize']).not_to be_nil
end
end
......@@ -167,6 +168,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
expect(json_response['RemoteObject']).to have_key('StoreURL')
expect(json_response['RemoteObject']).to have_key('DeleteURL')
expect(json_response['RemoteObject']).to have_key('MultipartUpload')
expect(json_response['MaximumSize']).not_to be_nil
end
end
......@@ -188,6 +190,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
expect(response).to have_gitlab_http_status(:ok)
expect(response.media_type).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE)
expect(json_response['TempPath']).not_to be_nil
expect(json_response['MaximumSize']).not_to be_nil
end
it 'fails to post too large artifact' do
......
......@@ -414,7 +414,14 @@ RSpec.describe ObjectStorage do
subject { uploader_class.workhorse_authorize(has_length: has_length, maximum_size: maximum_size) }
shared_examples 'returns the maximum size given' do
it "returns temporary path" do
expect(subject[:MaximumSize]).to eq(maximum_size)
end
end
shared_examples 'uses local storage' do
it_behaves_like 'returns the maximum size given' do
it "returns temporary path" do
is_expected.to have_key(:TempPath)
......@@ -422,8 +429,10 @@ RSpec.describe ObjectStorage do
expect(subject[:TempPath]).to include(described_class::TMP_UPLOAD_PATH)
end
end
end
shared_examples 'uses remote storage' do
it_behaves_like 'returns the maximum size given' do
it "returns remote store" do
is_expected.to have_key(:RemoteObject)
......@@ -438,6 +447,7 @@ RSpec.describe ObjectStorage do
expect(subject[:RemoteObject][:StoreURL]).to include(described_class::TMP_UPLOAD_PATH)
end
end
end
shared_examples 'uses remote storage with multipart uploads' do
it_behaves_like 'uses remote storage' 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