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

Upload config fail #2483 #2484

Merged
merged 1 commit into from
Jan 25, 2023
Merged

Upload config fail #2483 #2484

merged 1 commit into from
Jan 25, 2023

Conversation

kanecko
Copy link
Contributor

@kanecko kanecko commented Jan 25, 2023

Codefix provided by @FroggyFlox .
Tested by @kanecko on 15.4 V4.5.5-0.

[EDIT]
Fixes #2483
See issue text/comments for details.

Codefix provided by FroggyFlox.
Tested by kanecko on 15.4 V4.5.5-0.
@kanecko kanecko changed the title fixes #2483 fixes #2483: Upload config fail Jan 25, 2023
@phillxnet phillxnet changed the title fixes #2483: Upload config fail Upload config fail #2483 Jan 25, 2023
@FroggyFlox
Copy link
Member

Thanks a lot, @kanecko, for taking the time to create this PR and of course for testing the proposed fix in #2483.

A bit of explanation here, for reference.

Although I cannot reproduce exactly the issue detailed in #2483, I can reproduce the HTTP 400 error (Bad request) upon uploading a config backup file. In my case, however, no response content at all is returned and nothing can be found in the logs (rockstor logs, or gunicorn logs). The only error I could find (in addition to the HTTP 400 response) was the following in /var/log/nginx/error.log:

2023/01/23 16:08:33 [error] 14064#14064: *313 readv() failed (104: Connection reset by peer) while reading upstream, client: 192.168.122.1, server: ~^(?<myhost>.+)$, request: "POST /api/config-backup/file-upload HTTP/1.1", upstream: "http://127.0.0.1:8000/api/config-backup/file-upload", host: "buildvm", referrer: "https://buildvm/"

I thus looked further into gunicorn but I couldn't find any indication of error in its logs (even after increasing its log level). Increasing request size limits in nginx, gunicorn, and even Django itself didn't make a difference.

Looking back into our Django side of things, we are dealing with this upload request in the ConfigBackupUpload() class:

class ConfigBackupUpload(ConfigBackupMixin, rfc.GenericView):
parser_classes = (FileUploadParser, MultiPartParser)

We can here see we are using two parsers defined by Django Rest Framework: FileUploadParser and MultiPartParser. Their docs state:

The FileUploadParser is for usage with native clients that can upload the file as a raw data request. For web-based uploads, or for native clients with multipart upload support, you should use the MultiPartParser instead.

This thus recommends the use of MultiPartParser in our case, instead of FileUploadParser. We currently use both, which seems to conflict here.

The question is why is this showing up as a problem now for us, however, as this has always been the case (and working thus far). Note that #2483 appeared in 4.5.4, which could thus be related to our Django version update, or Django Rest Framework update.

@phillxnet, as you can see above, the reason why the error appeared is still uncleared to me and maybe we should look into this a bit further to make sure we're not missing the real reason for #2483 here. It may not be worth wasting too much time on that, however, as given DRF's docs quoted above, using only MultiPartParser seems like the appropriate way to go in our case upon a brief look.

@phillxnet
Copy link
Member

@kanecko Thanks from me also for testing and preparing this pr and attributing @FroggyFlox . Much appreciated.

@FroggyFlox Thanks for the exposition here, always best if we can have some context as to why, or why we think :) , a change was required. Other than the operational definition of course.

It may not be worth wasting too much time on that, however, as given DRF's docs quoted above, using only MultiPartParser seems like the appropriate way to go in our case upon a brief look.

Agreed. I'll do a final build test and if all is well I'll get this merged ready for our pending 4.5.6-0 release.

Copy link
Member

@phillxnet phillxnet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And rpm built and installed with this patch applied, successfully passed the testing outlined by @FroggyFlox in the following comment #2483 (comment) under the linked issue of #2483:
select-config-backup-file

config-backup-file-received

[25/Jan/2023 16:01:45] INFO [storageadmin.tasks:64] Task [restore_rockons], id: 70715cb9-7087-455c-8dc2-3743f2aad96f completed OK

@phillxnet phillxnet merged commit f9649a1 into rockstor:testing Jan 25, 2023
@kanecko kanecko deleted the kanecko-patch-1 branch January 25, 2023 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants