Bug 2016047
Summary: | uploading a duplicate file fails with undefined local variable or method upload_href for #<Actions::Pulp3::Repository::CommitUpload:0x00000000134e3f00> | ||
---|---|---|---|
Product: | Red Hat Satellite | Reporter: | Justin Sherrill <jsherril> |
Component: | Repositories | Assignee: | Justin Sherrill <jsherril> |
Status: | CLOSED ERRATA | QA Contact: | sganar |
Severity: | medium | Docs Contact: | |
Priority: | unspecified | ||
Version: | 6.10.0 | CC: | osousa, sganar, swadeley, zhunting |
Target Milestone: | 6.10.2 | Keywords: | Triaged |
Target Release: | Unused | Flags: | osousa:
needinfo-
|
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | tfm-rubygem-katello-4.1.1.41-1 | Doc Type: | If docs needed, set a value |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2022-01-19 14:40:57 UTC | Type: | --- |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Justin Sherrill
2021-10-20 17:10:34 UTC
Created from redmine issue https://projects.theforeman.org/issues/33748 Upstream bug assigned to jsherril Justin, Is it possible to get the steps that lead to this error? e.g. is it a sync, cv publish, promote...etc. Thanks! We've finally figured out how to reproduce this. This is not reproducible via hammer or the cli, only via the api and only if you DO NOT pass the 'checksum' option to the katello/api/v2/repositories/$ID/content_uploads api. If you do pass the checksum option, an upload_id is NOT returned but instead a content_unit_ref is returned and the client can skip the upload step and pass that to the import content api instead of an upload_id. 99% of users will not ever see this, you'd only see this if you wrote a custom script to upload files and chose not to upload the checksum argument (which is marked as optional). I will upload a reproducer script. To reproduce, download the attached script 'upload.sh' and download some rpm or srpm to a directory on the satellite (with credentials admin/changeme) 1) create 2 yum repos on a satellite 2) change the first two lines of the script to include the correct filename of the rpm/srpm and the repo id of the repository to upload it to 3) run the script 4) change the script to point to the 2nd repository id 5) run the script again Also, the error you get after the 'upload_href' error is fixed is: {'non_field_errors': [ErrorDetail(string='There is already a package with: arch=src, checksum_type=sha256, epoch=0, name=createrepo_c, pkgId=3c14cfe03d38f2d0b38b3197c6e9a2337fb03418a5b4ee71aa526ff344e5bdce, release=1.el7, version=0.17.1.', code='invalid')]} Note that the current understand of this bug involves custom scripting and api usage, and should not be hit via hammer. To workaround this issue until it is released, there are a couple options: 1) use hammer for the upload (hammer repository upload-content) 2) adjust your api usage to look for and use a new response parameter (content_unit_href) You can see an example here: https://github.com/Katello/hammer-cli-katello/blob/6a9143bd96d339d56350c82d668f6bc52e5db394/lib/hammer_cli_katello/repository.rb#L419-L433 When creating the upload request, if you pass in the sha256 checksum of the file you are uploading (along with the size) using a 'checksum' parameter. If the response includes a 'content_unit_href' attribute, you can skip the actual content upload api calls that do the actual uploading of the file, and instead pass that content_unit_href as a 'content_unit_id' into the import_uploads api. This is in essence identifying that the file has already been uploaded, and skipping a duplicate upload, going straight to importing it. Verified. Tested on Satellite 6.10.2 Snap 1.0 Steps followed: 1. Download the attached script 'upload.sh' and download some rpm or srpm to a directory on the satellite (with credentials admin/changeme) 2) Create 2 yum repos on a satellite 3) Change the first two lines of the script to include the correct filename of the rpm/srpm and the repo id of the repository to upload it to 4) Run the script 5) Change the script to point to the 2nd repository id 6) Run the script again Observation: srpm/rpm upload to the repository is successful, No error is observed. Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory (Moderate: Satellite 6.10.2 Async Bug Fix Update), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHSA-2022:0190 |