Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server aborts tus upload without error message when out of quota #4406

Closed
TheOneRing opened this issue Aug 17, 2022 · 19 comments
Closed

Server aborts tus upload without error message when out of quota #4406

TheOneRing opened this issue Aug 17, 2022 · 19 comments

Comments

@TheOneRing
Copy link
Contributor

Describe the bug

A clear and concise description of what the bug is.

Steps to reproduce

Steps to reproduce the behavior:

  1. Create a space with 1gb quota
  2. Post upload a 1.5gb file

Expected behavior

The server returns an http error code and an error message.

Actual behavior

The server closes the connection

Additional context

Add any other context about the problem here.

Client log:

08-17 11:52:20:299 [ info sync.httplogger ]:	"cee78197-c11a-4f5e-aeb1-e247376fc8aa: Request: POST https://ocis.owncloud.test/dav/spaces/1284d238-aa92-42ce-bdc4-0b0000009157$31f599a1-94e1-4dfb-8bc9-841a57066d05 Header: { X-OC-Mtime: 1660562513, Content-Type: application/offset+octet-stream, Content-Length: 100000000, Upload-Offset: 0, Tus-Resumable: 1.0.0, Upload-Metadata: filename L0dYMDE1MDMxLk1QNA==,checksum U0hBMSA5ZGYwZGU2Y2IxOWQ3NmU5NzBlZTZjOTA1ZDE3MGEwNWQ1MGNhYmE0, Upload-Length: 1584189756, Authorization: Bearer [redacted], User-Agent: Mozilla/5.0 (Windows) mirall/3.0.0.0-git (ownCloud, windows-10.0.22000 ClientArchitecture: x86_64 OsArchitecture: x86_64), Accept: */*, X-Request-ID: cee78197-c11a-4f5e-aeb1-e247376fc8aa, Original-Request-ID: cee78197-c11a-4f5e-aeb1-e247376fc8aa, } Data: [100000000 bytes of application/offset+octet-stream data]"
08-17 11:52:20:299 [ info sync.networkjob ]:	Created OCC::SimpleNetworkJob("https://ocis.owncloud.test/dav/spaces/1284d238-aa92-42ce-bdc4-0b0000009157$31f599a1-94e1-4dfb-8bc9-841a57066d05","POST", "cee78197-c11a-4f5e-aeb1-e247376fc8aa", "cee78197-c11a-4f5e-aeb1-e247376fc8aa") for OCC::PropagateUploadFileTUS(0x1edc019c5c0)
08-17 11:52:20:425 [ info sync.httplogger ]:	"cee78197-c11a-4f5e-aeb1-e247376fc8aa: Response: POST 0 (Error: Connection closed,) https://ocis.owncloud.test/dav/spaces/1284d238-aa92-42ce-bdc4-0b0000009157$31f599a1-94e1-4dfb-8bc9-841a57066d05 Header: { } Data: []"

Server log:

ocis_traefik-ocis-1      | {"level":"error","service":"storage-users","pkg":"rgrpc","traceid":"00000000000000000000000000000000","error":"error: insufficient storage: quota exceeded","status":{"code":19,"message":"insufficient storage","trace":"00000000000000000000000000000000"},"time":"2022-08-17T09:51:33.026394716Z","message":"failed to initiate upload"}
@TheOneRing
Copy link
Contributor Author

@michaelstingl @dragotin

@michaelstingl
Copy link
Contributor

@individual-it add API tests for quota-validation responses? Should behave same as oC10?

@individual-it
Copy link
Member

@michaelstingl oh man, we have no TUS API tests to check quota, added to our ToDo list

@michaelstingl
Copy link
Contributor

@TheOneRing suspects more cases, where the connection is sometimes closed without proper HTTP status code (token expiration for example)

@SwikritiT SwikritiT self-assigned this Aug 22, 2022
@C0rby C0rby self-assigned this Aug 22, 2022
@SwikritiT
Copy link
Contributor

SwikritiT commented Aug 23, 2022

@TheOneRing Hi I was trying to add some tests for this issue but it gives me correct HTTP status code 507 for this case.

create a project space as user1

curl -u user1:123456 -vk -X POST "https://host.docker.internal:9200/graph/v1.0/drives/" -d '{"Name":"Project Jupiter","driveType":"project","quota":{"total":1000000000}}'

create a tus resource

curl -vk -X POST -u user1:123456 'https://host.docker.internal:9200/remote.php/dav/spaces/<spaceid>' -H 'Tus-Resumable: 1.0.0' -H 'Upload-Length: 1584189756' -H 'Upload-Metadata: filename dGV4dEZpbGUudHh0'

While trying to create a tus resource server replies with 507

curl -vk -X POST -u user1:123456 'https://host.docker.internal:9200/remote.php/dav/spaces/1284d238-aa92-42ce-bdc4-0b0000009157$57e3f44b-9d76-4d74-80d8-ab5f4bdf828f' -H 'Tus-Resumable: 1.0.0' -H 'Upload-Length: 1584189756' -H 'Upload-Metadata: filename dGV4dEZpbGUudHh0'
*   Trying 127.0.0.1:9200...
* TCP_NODELAY set
* Connected to host.docker.internal (127.0.0.1) port 9200 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256
* ALPN, server did not agree to a protocol
* Server certificate:
*  subject: O=Acme Corp; CN=OCIS
*  start date: Aug 23 07:56:31 2022 GMT
*  expire date: Aug 23 07:56:31 2023 GMT
*  issuer: O=Acme Corp; CN=OCIS
*  SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
* Server auth using Basic with user 'user1'
> POST /remote.php/dav/spaces/1284d238-aa92-42ce-bdc4-0b0000009157$57e3f44b-9d76-4d74-80d8-ab5f4bdf828f HTTP/1.1
> Host: host.docker.internal:9200
> Authorization: Basic dXNlcjE6MTIzNDU2
> User-Agent: curl/7.68.0
> Accept: */*
> Tus-Resumable: 1.0.0
> Upload-Length: 1584189756
> Upload-Metadata: filename dGV4dEZpbGUudHh0
> 
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* Mark bundle as not supporting multiuse
< HTTP/1.1 507 Insufficient Storage
< Access-Control-Allow-Headers: Tus-Resumable, Upload-Length, Upload-Metadata, If-Match
< Access-Control-Allow-Origin: *
< Access-Control-Expose-Headers: Tus-Resumable, Location
< Content-Length: 0
< Content-Security-Policy: default-src 'none';
< Date: Tue, 23 Aug 2022 09:52:35 GMT
< Tus-Extension: creation,creation-with-upload,checksum,expiration
< Tus-Resumable: 1.0.0
< X-Content-Type-Options: nosniff
< X-Download-Options: noopen
< X-Frame-Options: SAMEORIGIN
< X-Permitted-Cross-Domain-Policies: none
< X-Robots-Tag: none
< X-Xss-Protection: 1; mode=block

I'll also make a PR adding tests coverage

@C0rby
Copy link
Contributor

C0rby commented Aug 23, 2022

I could reproduce the issue locally and found that the only difference is the Content-Length header.

See the log from the desktop client:

POST https://localhost:9200/remote.php/dav/files/admin/ Header: { X-OC-Mtime: 1582223355, Content-Type: application/offset+octet-stream, Content-Length: 100000000, Upload-Offset: 0, Tus-Resumable: 1.0.0, Upload-Metadata: filename L0Jvb2tzLnRhci5neg==,checksum U0hBMSBhZDNjNDEzY2Q0YWFjOGExMjRmNDBkYmI0NWM1NzA1NjAwMzdiYzlh, Upload-Length: 1369213294, Authorization: Bearer [redacted], User-Agent: Mozilla/5.0 (Linux) mirall/2.10.1 (build 7187) (ownCloud, pop-5.18.10-76051810-generic ClientArchitecture: x86_64 OsArchitecture: x86_64), Accept: */*, X-Request-ID: 4cf8b515-0fd2-4673-a5d6-b68c6730665c, Original-Request-ID: 4cf8b515-0fd2-4673-a5d6-b68c6730665c, } Data: [100000000 bytes of application/offset+octet-stream data]"

Using curl with the Content-Length header the connection never closes but without the header it works as expected.

@michaelstingl

This comment was marked as resolved.

@SwikritiT
Copy link
Contributor

Thanks, I missed the header. Behaves the same way for me as well with the Content-Length hearder

@C0rby
Copy link
Contributor

C0rby commented Aug 23, 2022

Using curl with the Content-Length header the connection never closes

Bug in the backend? Could we prioritise this @dragotin ?

I couldn't find any error in the backend and it only seems to happen when the Content-Length is smaller than the sent file size.

So in my case the file was 1.3Gb but the Header was 1.0Gb
If I provide the correct content length it works as expected.

curl -k -s -u admin:admin https://localhost:9200/remote.php/dav/files/admin/ -H 'Content-Type: application/offset+octet-stream' -H 'Upload-Offset: 0' -H 'Tus-Resumable: 1.0.0' -H 'Upload-Metadata: filename L0Jvb2tzLnRhci5neg==,checksum U0hBMSBhZDNjNDEzY2Q0YWFjOGExMjRmNDBkYmI0NWM1NzA1NjAwMzdiYzlh' -H 'Upload-Length: 1369213294' -H 'Content-Length: 1369213294' -T Books.tar.gz -v
*   Trying 127.0.0.1:9200...
* Connected to localhost (127.0.0.1) port 9200 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* TLSv1.0 (OUT), TLS header, Certificate Status (22):
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS header, Certificate Status (22):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS header, Finished (20):
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.2 (OUT), TLS header, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS header, Supplemental data (23):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256
* ALPN, server did not agree to a protocol
* Server certificate:
*  subject: O=Acme Corp; CN=OCIS
*  start date: Aug 16 09:22:38 2022 GMT
*  expire date: Aug 16 09:22:38 2023 GMT
*  issuer: O=Acme Corp; CN=OCIS
*  SSL certificate verify result: self-signed certificate (18), continuing anyway.
* Server auth using Basic with user 'admin'
* TLSv1.2 (OUT), TLS header, Supplemental data (23):
> PUT /remote.php/dav/files/admin/Books.tar.gz HTTP/1.1
> Host: localhost:9200
> Authorization: Basic YWRtaW46YWRtaW4=
> User-Agent: curl/7.81.0
> Accept: */*
> Content-Type: application/offset+octet-stream
> Upload-Offset: 0
> Tus-Resumable: 1.0.0
> Upload-Metadata: filename L0Jvb2tzLnRhci5neg==,checksum U0hBMSBhZDNjNDEzY2Q0YWFjOGExMjRmNDBkYmI0NWM1NzA1NjAwMzdiYzlh
> Upload-Length: 1369213294
> Content-Length: 1369213294
> Expect: 100-continue
>
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* Mark bundle as not supporting multiuse
< HTTP/1.1 507 Insufficient Storage
< Access-Control-Allow-Origin: *
< Content-Length: 0
< Content-Security-Policy: default-src 'none';
< Date: Tue, 23 Aug 2022 13:21:49 GMT
< X-Content-Type-Options: nosniff
< X-Download-Options: noopen
< X-Frame-Options: SAMEORIGIN
< X-Permitted-Cross-Domain-Policies: none
< X-Robots-Tag: none
< X-Xss-Protection: 1; mode=block
< Connection: close
<
* Closing connection 0
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* TLSv1.3 (IN), TLS alert, close notify (256):
* TLSv1.2 (OUT), TLS header, Supplemental data (23):
* TLSv1.3 (OUT), TLS alert, close notify (256):

Edit:
Also apparently only when I'm not actually sending any data.

@michaelstingl
Copy link
Contributor

I couldn't find any error in the backend and it only seems to happen when the Content-Length is smaller than the sent file size.

Then the error is, the backend just closes the connection, instead of responding with a meaningful status code and error message? What did oC10 respond in such cases?

@SwikritiT
Copy link
Contributor

I couldn't find any error in the backend and it only seems to happen when the Content-Length is smaller than the sent file size.

Then the error is, the backend just closes the connection, instead of responding with a meaningful status code and error message? What did oC10 respond in such cases?

TUS is not implemented in oc10.

Any thoughts here @individual-it @phil-davis?

@SwikritiT
Copy link
Contributor

SwikritiT commented Aug 25, 2022

@corby When I set the content-length header and sent the data equal to the set content length then the request works as expected.
For this request, I've created a space with a quota 10 and the upload length is 15 with content length 10 and data of 10 bytes

curl -vk -X POST -u user1:123456 'https://host.docker.internal:9200/remote.php/dav/spaces/1284d238-aa92-42ce-bdc4-0b0000009157$772cb6a0-33a1-447a-8e1c-73482f443476' -H 'Tus-Resumable: 1.0.0' -H 'Upload-Length: 15' -H 'Upload-Metadata: filename dGV4dEZpbGUudHh0' -H'Content-length: 10' -H'Content-Type: application/offset+octet-stream' -d"0123456789" 

In this case it returns with 507 as expected

Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 127.0.0.1:9200...
* TCP_NODELAY set
* Connected to host.docker.internal (127.0.0.1) port 9200 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256
* ALPN, server did not agree to a protocol
* Server certificate:
*  subject: O=Acme Corp; CN=OCIS
*  start date: Aug 25 05:48:55 2022 GMT
*  expire date: Aug 25 05:48:55 2023 GMT
*  issuer: O=Acme Corp; CN=OCIS
*  SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
* Server auth using Basic with user 'user1'
> POST /remote.php/dav/spaces/1284d238-aa92-42ce-bdc4-0b0000009157$772cb6a0-33a1-447a-8e1c-73482f443476 HTTP/1.1
> Host: host.docker.internal:9200
> Authorization: Basic dXNlcjE6MTIzNDU2
> User-Agent: curl/7.68.0
> Accept: */*
> Tus-Resumable: 1.0.0
> Upload-Length: 15
> Upload-Metadata: filename dGV4dEZpbGUudHh0
> Content-length: 10
> Content-Type: application/offset+octet-stream
> 
* upload completely sent off: 10 out of 10 bytes
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* Mark bundle as not supporting multiuse
< HTTP/1.1 507 Insufficient Storage
< Access-Control-Allow-Headers: Tus-Resumable, Upload-Length, Upload-Metadata, If-Match
< Access-Control-Allow-Origin: *
< Access-Control-Expose-Headers: Tus-Resumable, Location
< Content-Length: 0
< Content-Security-Policy: default-src 'none';
< Date: Thu, 25 Aug 2022 06:12:23 GMT
< Tus-Extension: creation,creation-with-upload,checksum,expiration
< Tus-Resumable: 1.0.0
< X-Content-Type-Options: nosniff
< X-Download-Options: noopen
< X-Frame-Options: SAMEORIGIN
< X-Permitted-Cross-Domain-Policies: none
< X-Robots-Tag: none
< X-Xss-Protection: 1; mode=block
< 
* Connection #0 to host host.docker.internal left intact

But if I send data lower that the set content length it hangs

 curl -vk -X POST -u user1:123456 'https://host.docker.internal:9200/remote.php/dav/spaces/1284d238-aa92-42ce-bdc4-0b0000009157$772cb6a0-33a1-447a-8e1c-73482f443476' -H 'Tus-Resumable: 1.0.0' -H 'Upload-Length: 15' -H 'Upload-Metadata: filename dGV4dEZpbGUudHh0' -H'Content-length: 10' -H'Content-Type: application/offset+octet-stream' -d"012345678" 
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 127.0.0.1:9200...
* TCP_NODELAY set
* Connected to host.docker.internal (127.0.0.1) port 9200 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256
* ALPN, server did not agree to a protocol
* Server certificate:
*  subject: O=Acme Corp; CN=OCIS
*  start date: Aug 25 05:48:55 2022 GMT
*  expire date: Aug 25 05:48:55 2023 GMT
*  issuer: O=Acme Corp; CN=OCIS
*  SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
* Server auth using Basic with user 'user1'
> POST /remote.php/dav/spaces/1284d238-aa92-42ce-bdc4-0b0000009157$772cb6a0-33a1-447a-8e1c-73482f443476 HTTP/1.1
> Host: host.docker.internal:9200
> Authorization: Basic dXNlcjE6MTIzNDU2
> User-Agent: curl/7.68.0
> Accept: */*
> Tus-Resumable: 1.0.0
> Upload-Length: 15
> Upload-Metadata: filename dGV4dEZpbGUudHh0
> Content-length: 10
> Content-Type: application/offset+octet-stream
> 
* upload completely sent off: 9 out of 9 bytes
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):

But if I send the data greater than the set content length it works again as expected, 507 is returned.
So is this expected behavior? In the case where we send the data lower than the set content-length, is the server waiting for the remaining data?

Also in the main issue it says that the connection closes but it just hangs for me?

@michaelstingl
Copy link
Contributor

TUS is not implemented in oc10.

I mean quota violations in general, not TUS specific.

@SwikritiT
Copy link
Contributor

TUS is not implemented in oc10.

I mean quota violations in general, not TUS specific.

Then 507 should be the expected status code.

@C0rby
Copy link
Contributor

C0rby commented Aug 31, 2022

Also in the main issue it says that the connection closes but it just hangs for me?

Yeah true, in that case the server is probably waiting for the remaining data, which makes sense.

@micbar
Copy link
Contributor

micbar commented Sep 6, 2022

@TheOneRing @C0rby Do we need a call to solve this?

@SwikritiT SwikritiT removed their assignment Sep 12, 2022
@michaelstingl
Copy link
Contributor

@TheOneRing @C0rby Is this fixed? Close? (my tests are always without quota)

@C0rby
Copy link
Contributor

C0rby commented Sep 27, 2022

After a short discussion we found that the headers are actually correct.
I'll have another look at the backend behavior.

@C0rby
Copy link
Contributor

C0rby commented Sep 29, 2022

I can't really reproduce this issue. My guess is that the initial error was correlating with an expired token or something like that. That would explain the POST 0 status code because that is also what we see in cases when the token expires and the requests get canceled.

@michaelstingl, can we close this issue for now and work on the token refresh issue first? If afterwards this issue appears again we can re-open it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

6 participants