Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2016047 - uploading a duplicate file fails with undefined local variable or method upload_href for #<Actions::Pulp3::Repository::CommitUpload:0x00000000134e3f00>
Summary: uploading a duplicate file fails with undefined local variable or method uplo...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Repositories
Version: 6.10.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: 6.10.2
Assignee: Justin Sherrill
QA Contact: sganar
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-10-20 17:10 UTC by Justin Sherrill
Modified: 2022-01-19 14:41 UTC (History)
4 users (show)

Fixed In Version: tfm-rubygem-katello-4.1.1.41-1
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-01-19 14:40:57 UTC
Target Upstream Version:
Embargoed:
osousa: needinfo-


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 33748 0 Normal Ready For Testing uploading a duplicate fail fails with undefined local variable or method upload_href for #<Actions::Pulp3::Repository::C... 2021-10-20 17:10:35 UTC
Red Hat Product Errata RHSA-2022:0190 0 None None None 2022-01-19 14:41:14 UTC

Description Justin Sherrill 2021-10-20 17:10:34 UTC
Unclear how to reproduce

Comment 1 Justin Sherrill 2021-10-20 17:10:38 UTC
Created from redmine issue https://projects.theforeman.org/issues/33748

Comment 2 Justin Sherrill 2021-10-20 17:11:16 UTC
Upstream bug assigned to jsherril

Comment 3 Brad Buckingham 2021-10-21 14:07:03 UTC
Justin,

Is it possible to get the steps that lead to this error?
e.g. is it a sync, cv publish, promote...etc.

Thanks!

Comment 4 Justin Sherrill 2021-10-28 12:41:52 UTC
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.

Comment 6 Justin Sherrill 2021-10-28 12:45:02 UTC
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

Comment 7 Justin Sherrill 2021-10-28 12:46:35 UTC
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')]}

Comment 8 Justin Sherrill 2021-11-09 13:58:00 UTC
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.

Comment 11 sganar 2021-12-27 08:36:29 UTC
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.

Comment 17 errata-xmlrpc 2022-01-19 14:40:57 UTC
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


Note You need to log in before you can comment on or make changes to this bug.