summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-09-13 15:58:04 -0700
committerStan Hu <stanhu@gmail.com>2018-09-14 07:43:39 -0700
commit244ed8adb3bc2d1b4706a695e19e144e180084f3 (patch)
treeb274dde215c9bcd40d4e9819acfb8f5d93249bac
parent32b96bfd81ff254142dbd9c73e1a494308213cb3 (diff)
downloadgitlab-ce-244ed8adb3bc2d1b4706a695e19e144e180084f3.tar.gz
Fix object storage uploads not working with AWS v2
Because we were passing query strings as symbols, the fog-aws storage driver was omitting the uploadId and partNumber query strings from the signature in multipart uploads. This fix makes AWS and Ceph work with v2 signatures. See: https://github.com/fog/fog-aws/blob/v3.0.0/lib/fog/aws/storage.rb#L733 Closes https://gitlab.com/gitlab-org/gitlab-workhorse/issues/181
-rw-r--r--changelogs/unreleased/sh-fix-multipart-upload-signed-urls.yml5
-rw-r--r--lib/object_storage/direct_upload.rb6
-rw-r--r--spec/lib/object_storage/direct_upload_spec.rb10
3 files changed, 18 insertions, 3 deletions
diff --git a/changelogs/unreleased/sh-fix-multipart-upload-signed-urls.yml b/changelogs/unreleased/sh-fix-multipart-upload-signed-urls.yml
new file mode 100644
index 00000000000..994765bc1fd
--- /dev/null
+++ b/changelogs/unreleased/sh-fix-multipart-upload-signed-urls.yml
@@ -0,0 +1,5 @@
+---
+title: Fix object storage uploads not working with AWS v2
+merge_request: 21731
+author:
+type: fixed
diff --git a/lib/object_storage/direct_upload.rb b/lib/object_storage/direct_upload.rb
index ab43910c8bd..97f56e10ccf 100644
--- a/lib/object_storage/direct_upload.rb
+++ b/lib/object_storage/direct_upload.rb
@@ -89,7 +89,7 @@ module ObjectStorage
method: 'PUT',
bucket_name: bucket_name,
object_name: object_name,
- query: { uploadId: upload_id, partNumber: part_number },
+ query: { 'uploadId' => upload_id, 'partNumber' => part_number },
headers: upload_options
}, expire_at)
end
@@ -100,7 +100,7 @@ module ObjectStorage
method: 'POST',
bucket_name: bucket_name,
object_name: object_name,
- query: { uploadId: upload_id },
+ query: { 'uploadId' => upload_id },
headers: { 'Content-Type' => 'application/xml' }
}, expire_at)
end
@@ -111,7 +111,7 @@ module ObjectStorage
method: 'DELETE',
bucket_name: bucket_name,
object_name: object_name,
- query: { uploadId: upload_id }
+ query: { 'uploadId' => upload_id }
}, expire_at)
end
diff --git a/spec/lib/object_storage/direct_upload_spec.rb b/spec/lib/object_storage/direct_upload_spec.rb
index 9c308cc1be9..1024e1a25ea 100644
--- a/spec/lib/object_storage/direct_upload_spec.rb
+++ b/spec/lib/object_storage/direct_upload_spec.rb
@@ -83,6 +83,16 @@ describe ObjectStorage::DirectUpload do
expect(subject[:MultipartUpload][:AbortURL]).to start_with(storage_url)
expect(subject[:MultipartUpload][:AbortURL]).to include('uploadId=myUpload')
end
+
+ it 'uses only strings in query parameters' do
+ expect(direct_upload.send(:connection)).to receive(:signed_url).at_least(:once) do |params|
+ if params[:query]
+ expect(params[:query].keys.all? { |key| key.is_a?(String) }).to be_truthy
+ end
+ end
+
+ subject
+ end
end
shared_examples 'a valid upload without multipart data' do