Skip to content

HMS-5790: cannot change size of upload #1102

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

xbhouse
Copy link
Contributor

@xbhouse xbhouse commented May 2, 2025

Summary

Adds the size of the upload to the uploads table and takes the size into account when creating an upload

Testing steps

  1. Create an upload via the API and specify a size that's smaller than the chunk size:
curl --location 'localhost:8000/api/content-sources/v1.0/repositories/uploads/' \
--header 'x-rh-identity: <identity>' \
--header 'Content-Type: application/json' \
--data '{
    "size": 7050,
    "chunk_size": 7068,
    "sha256": "08d4c0799e06278e5c6aba9b2b979c55802c5ec6083906220d712bf0031a8450"
}'

{
  "upload_uuid":"01969199-f854-712c-a1a4-6497c73a6d03",
  "created":"2025-05-02T15:25:09.077058Z",
  "last_updated":"2025-05-02T15:25:09.077071Z",
  "size":7050
}

You should see an upload created in the uploads table in the content sources db and when listing uploads (pulp upload list) via the pulp CLI.

  1. Recreate the upload with the same sha and chunk size, but with the correct size of the rpm. You should see a new upload created with a different UUID than the first one.

  2. Uploading a chunk to the original upload (the one with the wrong size) should fail, this is expected:

curl --location 'localhost:8000/api/content-sources/v1.0/repositories/uploads/01969199-f854-712c-a1a4-6497c73a6d03/upload_chunk/' \
--header 'x-rh-identity: <identity>' \
--header 'Content-Range: bytes 0-7067/*' \ 
--form 'file=@"/Users/bhouse/rpms/testfileaa"' \      
--form 'sha256="08d4c0799e06278e5c6aba9b2b979c55802c5ec6083906220d712bf0031a8450"'  

{"errors":[{"status":400,"title":"error uploading chunk","detail":"uploading file chunk: 400 Bad Request: {\"non_field_errors\":[\"End byte is greater than upload size.\"]}"}]}

Uploading a chunk to the new upload (the one with the correct size) should succeed.

  1. Uploading rpms in the UI and upload cleanup (go run cmd/external-repos/main.go upload-cleanup) should still work as before.

@jlsherrill
Copy link
Member

@xbhouse xbhouse marked this pull request as ready for review May 3, 2025 00:15
@rverdile rverdile self-assigned this May 6, 2025
Copy link
Contributor

@rverdile rverdile left a comment

Choose a reason for hiding this comment

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

looks good!

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

Successfully merging this pull request may close these issues.

3 participants