S3 Object storage uploads fail with unclear message if region not specified

Summary

Uploading artifacts to an S3 compatible storage (minio) with consolidated object storage fails.

Steps to reproduce

WARNING: Uploading artifacts as "archive" to coordinator... failed id=44102 responseStatus=500 Internal Server Error status=500 token=gZZiPr18
WARNING: Retrying... context=artifacts-uploader error=invalid argument
WARNING: Uploading artifacts as "archive" to coordinator... failed id=44102 responseStatus=500 Internal Server Error status=500 token=gZZiPr18
WARNING: Retrying... context=artifacts-uploader error=invalid argument
WARNING: Uploading artifacts as "archive" to coordinator... failed id=44102 responseStatus=500 Internal Server Error status=500 token=gZZiPr18 

What is the current bug behavior?

Uploads fails

What is the expected correct behavior?

Uploads should work

Relevant logs and/or screenshots

After receiving the errors I did a tcpdump, this is the request:

PUT /gitlab-artifacts/tmp/uploads/1610361819-19742-0001-6405-ed9a15b48d0393cb2b28d00517ed2a67?X-Amz-Expires=15300&X-Amz-Date=20210111T104339Z&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=[masked]&X-Amz-SignedHeaders=host&X-Amz-Signature=[masked] HTTP/1.1
Host: s3.minio
User-Agent: Go-http-client/1.1
Transfer-Encoding: chunked
Accept-Encoding: gzip 

and the answer:

HTTP/1.1 411 Length Required
Accept-Ranges: bytes
Content-Length: 479
Content-Security-Policy: block-all-mixed-content
Content-Type: application/xml
Server: MinIO
Vary: Origin
X-Amz-Request-Id: 1659278AFBB3C3EC
X-Xss-Protection: 1; mode=block
Date: Mon, 11 Jan 2021 10:43:39 GMT

<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>MissingContentLength</Code><Message>You must provide the Content-Length HTTP header.</Message><Key>tmp/uploads/1610361819-19742-0001-6405-ed9a15b48d0393cb2b28d00517ed2a67</Key><BucketName>gitlab-artifacts</BucketName><Resource>/gitlab-artifacts/tmp/uploads/1610361819-19742-0001-6405-ed9a15b48d0393cb2b28d00517ed2a67</Resource><RequestId>1659278AFBB3C3EC</RequestId><HostId>d1445834-4b91-498f-a91b-a42f2c628149</HostId></Error> 

Personally I think minio is right, AWS S3 does not support chunked uploads like that to the best of my knowledge.

Logs show the failure as well:

{"correlation_id":"01EVRGPM9DE2QMW71SCV78T898","error":"handleFileUploads: extract files from multipart: persisting multipart file: PUT request http://s3.minio/gitlab-artifacts/tmp/uploads/1610361819-19742-0001-6405-ed9a15b48d0393cb2b28d00517ed2a67?X-Amz-Expires=15300\u0026X-Amz-Date=20210111T104339Z\u0026X-Amz-Algorithm=AWS4-HMAC-SHA256\u0026X-Amz-Credential=[FILTERED]%2Fus-east-1%2Fs3%2Faws4_request\u0026X-Amz-SignedHeaders=host\u0026X-Amz-Signature=[FILTERED] returned: 411 Length Required","level":"error","method":"POST","msg":"error","time":"2021-01-11T11:43:39+01:00","uri":"/api/v4/jobs/44102/artifacts?artifact_format=zip\u0026artifact_type=archive\u0026expire_in=1+day"}
{"content_type":"text/plain; charset=utf-8","correlation_id":"01EVRGPM9DE2QMW71SCV78T898","duration_ms":208,"host":"gitlab.xxx","level":"info","method":"POST","msg":"access","proto":"HTTP/1.1","referrer":"","remote_addr":"127.0.0.1:0","remote_ip":"127.0.0.1","route":"^/api/v4/jobs/[0-9]+/artifacts\\z","status":500,"system":"http","time":"2021-01-11T11:43:39+01:00","ttfb_ms":208,"uri":"/api/v4/jobs/44102/artifacts?artifact_format=zip\u0026artifact_type=archive\u0026expire_in=1+day","user_agent":"gitlab-runner 13.7.0 (13-7-stable; go1.13.8; linux/amd64)","written_bytes":22} 

I found a workaround by issuing:

Feature.disable(:use_workhorse_s3_client)

which seems to trigger the (older?) working multipart upload again: https://gitlab.com/gitlab-org/gitlab/-/blob/master/workhorse/internal/filestore/file_handler.go#L133-149

Results of GitLab environment info

Expand for output related to GitLab environment info
System information
System:		
Proxy:		no
Current User:	git
Using RVM:	no
Ruby Version:	2.7.2p137
Gem Version:	3.1.4
Bundler Version:2.1.4
Rake Version:	13.0.1
Redis Version:	5.0.9
Git Version:	2.29.0
Sidekiq Version:5.2.9
Go Version:	unknown

GitLab information
Version:	13.7.3-ee
Revision:	925686b2c52
Directory:	/opt/gitlab/embedded/service/gitlab-rails
DB Adapter:	PostgreSQL
DB Version:	12.5
URL:		https://gitlab.xxx
HTTP Clone URL:	https://gitlab.xxx/some-group/some-project.git
SSH Clone URL:	git@git.xxx:some-group/some-project.git
Elasticsearch:	no
Geo:		no
Using LDAP:	yes
Using Omniauth:	yes
Omniauth Providers: 

GitLab Shell
Version:	13.14.0
Repository storage paths:
- default: 	/var/opt/gitlab/git-data/repositories
GitLab Shell path:		/opt/gitlab/embedded/service/gitlab-shell
Git:		/opt/gitlab/embedded/bin/git

Results of GitLab application Check

Expand for output related to the GitLab application check

Checking GitLab subtasks ...

Checking GitLab Shell ...

GitLab Shell: ... GitLab Shell version >= 13.14.0 ? ... OK (13.14.0) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Internal API available: OK Redis available via internal API: OK gitlab-shell self-check successful

Checking GitLab Shell ... Finished

Checking Gitaly ...

Gitaly: ... default ... OK

Checking Gitaly ... Finished

Checking Sidekiq ...

Sidekiq: ... Running? ... yes Number of Sidekiq processes ... 1

Checking Sidekiq ... Finished

Checking Incoming Email ...

Incoming Email: ... Reply by email is disabled in config/gitlab.yml

Checking Incoming Email ... Finished

Checking LDAP ...

LDAP: ... Server: ldapmain LDAP authentication... Success LDAP users with access to your GitLab server (only showing the first 100 results) User output sanitized. Found 20 users of 100 limit.

Checking LDAP ... Finished

Checking GitLab App ...

Git configured correctly? ... yes Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... yes Init script exists? ... skipped (omnibus-gitlab has no init script) Init script up-to-date? ... skipped (omnibus-gitlab has no init script) Projects have namespace: ... 2/1 ... yes 2/3 ... yes 2/4 ... yes 14/5 ... yes 2/6 ... yes 2/7 ... yes 3/8 ... yes 6/9 ... yes 2/11 ... yes 2/12 ... yes 2/13 ... yes 2/14 ... yes 2/15 ... yes 2/17 ... yes 3/20 ... yes 2/21 ... yes 2/22 ... yes 3/23 ... yes 2/24 ... yes 2/27 ... yes 20/31 ... yes 20/32 ... yes 2/41 ... yes 28/42 ... yes 28/43 ... yes 14/47 ... yes 14/48 ... yes 14/49 ... yes 14/50 ... yes 14/52 ... yes 14/54 ... yes 29/55 ... yes 2/56 ... yes 14/57 ... yes 14/59 ... yes 14/60 ... yes 3/61 ... yes 14/62 ... yes 14/63 ... yes 14/64 ... yes 14/65 ... yes 3/66 ... yes 14/67 ... yes 14/68 ... yes Redis version >= 4.0.0? ... yes Ruby version >= 2.7.2 ? ... yes (2.7.2) Git version >= 2.29.0 ? ... yes (2.29.0) Git user has default SSH configuration? ... yes Active users: ... 18 Is authorized keys file accessible? ... yes GitLab configured to store new projects in hashed storage? ... yes All projects are in hashed storage? ... yes Elasticsearch version 7.x (6.4 - 6.x deprecated to be removed in 13.8)? ... skipped (elasticsearch is disabled)

Checking GitLab App ... Finished

Checking GitLab subtasks ... Finished

Possible fixes

Edited by Stan Hu