Bug 2207867

Summary: Getting "[Errno -1] Package does not match intended download" error when install rpm
Product: Red Hat Satellite Reporter: Hao Chang Yu <hyu>
Component: PulpAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED MIGRATED QA Contact: Satellite QE Team <sat-qe-bz-list>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.11.5CC: akapse, christian.hoffmann2, dalley, jpasqual, kkinge
Target Milestone: UnspecifiedKeywords: MigratedToJIRA, Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2024-06-06 16:14:19 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Hao Chang Yu 2023-05-17 07:09:15 UTC
Description of problem:

In the case of "on demand" download policy, if there are multiple remote URL for the similar rpms (same NVERA but have different checksum), Pulp may pick the wrong remote URL to download the rpm.

This can happen when some third party repositories re-signed Red Hat rpm without changing the rpm name. Customer syncs both Red Hat repository and the third party repository containing the same rpm.


Steps to Reproduce:
1. Prepare any unsigned rpm, such as foo-1.0-1.noarch.rpm
2. Make a copy of the unsigned rpm and then sign it with a gpg key.
3. In the Satellite "/var/www/html/pub" directory, create the following 2 directories.
~~~
/var/www/html/pub/test_repo_redhat
/var/www/html/pub/test_repo_custom
~~~

4. Copy the signed rpm to both directories.
5. Run createrepo command in both directory.
6. In Satellite web ui, create the following 2 custom repositories:
~~~
name: test_repo_redhat
Upstream_url: http://your.satellite.fqdn/pub/test_repo_redhat/
Download policy: On demand

name: test_repo_custom
Upstream_url: http://your.satellite.fqdn/pub/test_repo_custom/
Download policy: On demand
~~~

7. Sync both repositories.
8. If you run the following sql query, you should get something like below:
~~~
Example:

Pulpcore=# select url, sha256 from core_remoteartifact where url ilike '%foo-1.0-1%';
                                                     url              |                              sha256                              
--------------------------------------------------------------------- +-----------------------------------------------------------------
 http://your.satellite.fqdn/pub/test_repo_redhat/foo-1.0-1.noarch.rpm | 6c3d14090ee0efdd7dba9fbabb5fb54bf403e76000e1137652dd62162ce3aa17
 http://your.satellite.fqdn/pub/test_repo_custom/foo-1.0-1.noarch.rpm | 6c3d14090ee0efdd7dba9fbabb5fb54bf403e76000e1137652dd62162ce3aa17
~~~

9. Remove everything in the "/var/www/html/pub/test_repo_custom" directory.
10. Copy the unsigned 'foo-1.0-1.noarch.rpm" to "/var/www/html/pub/test_repo_custom" directory and run createrepo.
11. Now sync the "test_repo_custom" repository again.
12. If you run the following sql query now, you should see the duplicate remote URL with new checksum (checksum of the unsigned rpm).
~~~
Example:

Pulpcore=# select url,sha256 from core_remoteartifact where url ilike '%foo-1.0-1%';
                                                     url              |                              sha256                              
--------------------------------------------------------------------- +-----------------------------------------------------------------
 http://your.satellite.fqdn/pub/test_repo_redhat/foo-1.0-1.noarch.rpm | 6c3d14090ee0efdd7dba9fbabb5fb54bf403e76000e1137652dd62162ce3aa17
 http://your.satellite.fqdn/pub/test_repo_custom/foo-1.0-1.noarch.rpm | 6c3d14090ee0efdd7dba9fbabb5fb54bf403e76000e1137652dd62162ce3aa17
 http://your.satellite.fqdn/pub/test_repo_custom/foo-1.0-1.noarch.rpm | ebebedda75647f51ef52499040d72ea704677ab0bc2f73bb312e9133b4a32f70
~~~


Actual results:
Download the rpm in "test_repo_redhat" repository will get the wrong rpm. Expected "6c3d14090ee0efdd7dba9fbabb5fb54bf403e76000e1137652dd62162ce3aa17"(signed rpm) but got "ebebedda75647f51ef52499040d72ea704677ab0bc2f73bb312e9133b4a32f70"(unsigned rpm)
~~~
Example:

# curl -k https://your.satellite.fqdn/pulp/content/org/Library/custom/custom/test_repo_redhat/Packages/f/foo-1.0-1.noarch.rpm | sha256sum
ebebedda75647f51ef52499040d72ea704677ab0bc2f73bb312e9133b4a32f70

# curl -k https://your.satellite.fqdn/pulp/content/org/Library/custom/custom/test_repo_redhat/repodata/xxxxxxx-primary.xml.gz | gunzip | grep "checksum"
<checksum type="sha256" pkgid="YES">6c3d14090ee0efdd7dba9fbabb5fb54bf403e76000e1137652dd62162ce3aa17</checksum>
~~~


Expected results:
Downloaded rpm match the repo metadata.

Comment 11 Eric Helms 2024-06-06 16:14:19 UTC
This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there.

Due to differences in account names between systems, some fields were not replicated.  Be sure to add yourself to Jira issue's "Watchers" field to continue receiving updates and add others to the "Need Info From" field to continue requesting information.

To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "SAT-" followed by an integer.  You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like:

"Bugzilla Bug" = 1234567

In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues. You can also visit https://access.redhat.com/articles/7032570 for general account information.