-
Notifications
You must be signed in to change notification settings - Fork 167
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
theforeman.foreman.content_upload fails with error "non_field_errors: Chunk size does not match content range." #1043
Comments
Thanks for the report! Do you know from the top of your head whether you're using pilp2 or pulp3 for file contents? If that's a fresh Katello 3.16 it should be 3, but on upgraded installs it might be either. I'll look what hammer does. |
Interestingly, our chunk size is even smaller than hammers...
|
I got this from
I think this katello instance was upgraded from 3.15 |
Thanks, I finally managed to find some time and repro this on a fresh 3.16. Will dig further. |
I think we need to port Katello/hammer-cli-katello@9276ae5 |
Glad to hear you could reproduce the issue and found a possible fix. Let me know if you want me to do some testing. |
Weird, we have the size parameter implemented since #659 |
The only other commit in hammer that touches this is Katello/hammer-cli-katello@0d0f877#diff-fe176ff6849ed0578304d0d8c0aa8b54fefa5acb8ba48579cb94748b3d14829f |
Okay, so the following patch should fix it for you: --- plugins/modules/content_upload.py
+++ plugins/modules/content_upload.py
@@ -174,7 +174,7 @@ def main():
with open(b_src, 'rb') as contentfile:
for chunk in iter(lambda: contentfile.read(CONTENT_CHUNK_SIZE), b""):
- data = {'content': chunk, 'offset': offset, 'size': len(chunk)}
+ data = {'content': chunk, 'offset': offset, 'size': size}
module.resource_action('content_uploads', 'update', params=content_upload_scope, data=data)
offset += len(chunk) Now I just need to find out why it worked before XD |
Maybe no one ever chunked a file before... |
I do almost daily, just not against Pulp3, so it seems its ignored on Pulp3 installs. |
Hmm, looking at pulp code, there is no evidence that the size field is used anywhere. Not sure, how katello translates that though. Pulp expects the content range as a header specifying start and end byte. https://github.com/pulp/pulpcore/blob/master/pulpcore/app/serializers/upload.py#L27 |
Yeah, before the patch, the Katello generated header was "range bytes 2097152-2097152/2097152", which is so wrong ;) |
Sure but still only the first two numbers of that content range are processed by pulp. Katello is capping finish with size, which when given the chunk size, will produce exactly that in the second chunk. |
I tested the patch and I could upload the file. Thanks @evgeni ! |
SUMMARY
theforeman.foreman.content_upload
fails with error"non_field_errors: Chunk size does not match content range."
when uploading this binary fileThe same tasks works ok when uploading a small txt file instead of a binary file
The file triggering the error can be uploaded using hammer doing
hammer repository upload-content --organization-id 1 --id 1548 --content-type file --path /tmp/docker-compose-Linux-x86_64
. Hammer upload test is done from the same host where katello is running. Ansible task triggering the error is executed from a different host.ISSUE TYPE
ANSIBLE VERSION
COLLECTION VERSION
KATELLO/FOREMAN VERSION
STEPS TO REPRODUCE
EXPECTED RESULTS
File should be uploaded to the repository but it fails. The same task works OK when uploading a small txt file. e.g
The text was updated successfully, but these errors were encountered: