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 2151657 - Package name conflict uploading the packages with the same name
Summary: Package name conflict uploading the packages with the same name
Keywords:
Status: ASSIGNED
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Pulp
Version: 6.11.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: Unspecified
Assignee: satellite6-bugs
QA Contact: Satellite QE Team
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-12-07 18:13 UTC by Aldrey Souza
Modified: 2023-10-08 00:24 UTC (History)
14 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-02-23 16:18:05 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Aggregated upstream fixes for Satellite 6.12.2 (2.06 KB, patch)
2023-03-31 16:02 UTC, Paul Donohue
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Github pulp pulp_rpm issues 2678 0 None open Pulp doesn't handle conflicting package filenames properly 2023-05-23 05:21:47 UTC
Red Hat Issue Tracker SAT-19992 0 None None None 2023-09-11 22:01:50 UTC

Description Aldrey Souza 2022-12-07 18:13:49 UTC
Description of problem:
The Satellite allows uploading packages with the same name in the same repository but only allows to download of the last one.

Version-Release number of selected component (if applicable):
Satellite 6.11.4.1-1

How reproducible:
Create a custom repository and upload the packages with the same name.

Steps to Reproduce:
1. Create a custom repository
2. Rename the first package as 'fubar.rpm'
3. Upload the first package
4. Rename the second package as 'fubar.rpm'
5. Upload the second package
6. Rename the third package as 'fubar.rpm'
7. Upload the third package
8. Try to download the first package
9. Try to download the second package
10. Try to download the third package

Actual results:
See 3 packages but only allow to download the third package

Expected results:
See 3 packages and download all of them


Additional info:

Comment 3 Daniel Alley 2023-02-23 06:11:12 UTC
Regarding 

>>>>>>
Steps to Reproduce:
1. Create a custom repository
2. Rename the first package as 'fubar.rpm'
3. Upload the first package
4. Rename the second package as 'fubar.rpm'
5. Upload the second package
6. Rename the third package as 'fubar.rpm'
7. Upload the third package
8. Try to download the first package
9. Try to download the second package
10. Try to download the third package

Actual results:
See 3 packages but only allow to download the third package

Expected results:
See 3 packages and download all of them
>>>>>>

This isn't possible, you cannot have 3 different files sharing the same path name and download all of them.  There is no way to do that regardless of whether you're talking about files or URLs, without changing one of the paths or letting one of them "win".

So I would say that this issue *as written* is invalid. That doesn't mean that the UX cannot be improved, but we need to figure out some way to improve the UX without breaking the laws of the universe :)

In the interim I would recommend not uploading all packages with the name "fubar.rpm" or any pattern similar to this. RPM file names should follow the pattern $name-$version-$release.$arch.rpm

Unfortunately ther is a fundamental contradiction between the needs of users who want Satellite to respect the filename they provided so that they know what to expect from the URLs and can provide the exact filename to yum/dnf, and users who provide nonsensical filenames and want Satellite to do something to work around that, and it's pretty challenging to make everyone happy in that respect.

Here are two semi-related BZs to look at: https://bugzilla.redhat.com/show_bug.cgi?id=2161993, https://bugzilla.redhat.com/show_bug.cgi?id=2162591

If there is an issue which neither of those covers and which makes sense to address, then please file a new BZ.

Comment 5 Paul Donohue 2023-03-30 17:14:59 UTC
Yum repositories are only supposed to contain RPMs named $name-$version-$release.$arch.rpm
Unfortunately, some vendors that provide RPMs do not correctly name their RPM files.  For example, IBM provides RPMs for Tivoli, but does not include the version/release in the filename: TIVsm-API64.x86_64.rpm

In previous versions of Satellite (Prior to the switch from Pulp 2 to Pulp 3), Satellite would automatically rename an uploaded RPM file as needed (by extracting the name/version/release/arch from the RPM itself).
In Satellite 6.11, RPMs are not renamed automatically by Satellite, and uploading multiple RPMs with the same filename appears to work at upload time, but then breaks things when you subsequently try to install those files with `yum`.

I consider this to be a bug in Satellite.  At the very least, Satellite should prevent uploads with improper filenames and provide the user with instructions/documentation for renaming the file appropriately.  Ideally, the automatic renaming behavior that existed with Pulp 2 should be restored so that users don't need to manually rename files.

Comment 6 Paul Donohue 2023-03-30 18:00:06 UTC
For more history/details/examples, please see RedHat case 03309188

Comment 7 Daniel Alley 2023-03-30 21:39:22 UTC
@Paul The problem is that there's a whole other (and seemingly large) set of users who upload a file with a given name and want to be able to "dnf install" using exactly that name, and consider it a bug that they cannot do so.  See https://bugzilla.redhat.com/show_bug.cgi?id=2162591

Automatic renaming is not compatible with that, because of course whatever you suggested the name should be originally might be ignored.

However I do hear your concern about the UX not being ideal - we should address that, and something along the lines of your backup suggestion is entirely reasonable.

Comment 8 Paul Donohue 2023-03-31 01:44:20 UTC
I think you are mistaken on a few points.

"dnf install <name>" matches the RPM name listed in the yum repository metadata (which in turn is extracted from the metadata within the RPM).  It does NOT match the filename of the uploaded RPM file.
For example, in https://bugzilla.redhat.com/show_bug.cgi?id=2162591 the filename is "jdk-8u361-linux-x64.rpm", but the RPM metadata within that file includes "name: jdk1.8", "epoch: 2000", "version: 1.8.0_361", "release: fcs".
Regardless of whether or not the file is renamed by Satellite/Pulp, you cannot run "dnf install jdk" or "dnf install jdk-8u361" or "dnf install "jdk-8u361-linux-x64" or anything similar.  You can only run "dnf install jdk1.8" or "dnf install jdk1.8-2000:1.8.0_361-fcs" or similar.  Even if Satellite/Pulp preserves the filename, I don't believe there are any command line arguments to DNF that will operate on any part of that "jdk-8u361-linux-x64.rpm" filename; DNF will only operate using values that match the RPM metadata.

I believe the only things that DNF uses the RPM filename for are the URL that DNF uses to retrieve the file, and the filename that is written if you run `dnf download ...`
I would be surprised if any users care what the URL is as long as DNF works properly when using it.  (Note that the whole problem here is that preserving the original filename causes Pulp and/or DNF to misbehave in a number of cases.  Automatically renaming the file would avoid all of that.)
I would also be surprised if anyone would prefer a mal-formed filename to be preserved by `dnf download ...`, as opposed to being replaced with a well-formed filename.

My read of https://bugzilla.redhat.com/show_bug.cgi?id=2162591 is that they are NOT asking for the filename to be preserved.  Rather, they are asking the same thing that I am - For Satellite to restore the Pulp 2 behavior that renamed the file automatically, since Pulp 2 was working fine for their use case but now Pulp 3 is not.

I'll admit that I don't follow Pulp bug reports closely, so I could be missing something.  However, I have not seen anyone state that they consider automatic RPM file renaming to be a bug, and I am not aware of any code paths or use cases where preserving the original filename would be preferable over automatically renaming the RPM file.
Note that Satellite has been automatically renaming RPMs for decades (all versions of Satellite 5 renamed RPMs, and Satellite 6 did up until 6.10), so even if preservation of the original filename is considered a "new feature", it shouldn't be rolled out until all of the existing use cases can be addressed without major regressions (like the regressions we are seeing here and in https://bugzilla.redhat.com/show_bug.cgi?id=2161993 and https://bugzilla.redhat.com/show_bug.cgi?id=2162591).

Comment 15 Paul Donohue 2023-03-31 16:02:40 UTC
Created attachment 1954920 [details]
Aggregated upstream fixes for Satellite 6.12.2

Comment 16 Paul Donohue 2023-03-31 16:07:12 UTC
Upstream fixes:
https://github.com/pulp/pulp_rpm/issues/3039
https://github.com/Katello/katello/pull/10329

To apply to Satellite 6.12.2:
ssh satellite
sudo -s
patch -p0 < fix-2151657.patch
satellite-maintain service restart

That will fix new uploads, but will not fix existing uploads.

To attempt to fix some existing uploads that were broken due to an epoch in location_href, I tried:
sudo -u postgres psql pulpcore
select location_href from rpm_package where location_href LIKE '%:%';
update rpm_package set location_href='...' where location_href='...';
\q
satellite-maintain service restart
# Re-publish and promote Content Views.

However, that didn't seem to fix the published repository metadata, so DNF is still failing to download the relevant RPMs.

Any suggestions for how to fix the existing uploads, other than deleting and re-uploading them?

Comment 17 Hao Chang Yu 2023-04-03 03:20:07 UTC
Hi

> That will fix new uploads, but will not fix existing uploads.
> 
> To attempt to fix some existing uploads that were broken due to an epoch in
> location_href, I tried:
> sudo -u postgres psql pulpcore
> select location_href from rpm_package where location_href LIKE '%:%';
> update rpm_package set location_href='...' where location_href='...';
> \q

I suggest you to fix the relative_path (which has the wrong format of filename) instead of fixing the location_href.

> satellite-maintain service restart
> # Re-publish and promote Content Views.
> 
> However, that didn't seem to fix the published repository metadata, so DNF
> is still failing to download the relevant RPMs.
> 
> Any suggestions for how to fix the existing uploads, other than deleting and
> re-uploading them?

You need to force regenerate metadata of the default organization view custom repository and then publish and promote new version of any related content views.


Do you have a support case open? If you need further support, I suggest you to raise a Red Hat support case and refer to this bugzilla.

Comment 18 Paul Donohue 2023-04-06 21:00:24 UTC
For anyone else following along:

If you uploaded an RPM that did not have the expected filename at upload time, then you need to manually fix relative_path:
sudo -u postgres psql pulpcore
select relative_path from core_contentartifact where relative_path LIKE 'fubar%';
update rpm_package set relative_path='...' where pulp_id='...';
\q

If you uploaded an RPM that had an epoch set in its metadata (whether or not it was uploaded with the proper filename), then you need to manually fix location_href and filename:
sudo -u postgres psql pulpcore
select location_href from rpm_package where location_href LIKE '%:%';
update rpm_package set location_href='...' where location_href='...';
\q
sudo -u postgres psql foreman
select filename from katello_rpms where filename LIKE '%:%';
update katello_rpms set filename='...' where filename='...';
\q

After that, you need to run `satellite-maintain service restart` (or reboot the Satellite server) to ensure that all of the processes pick up the new DB data.

Reading the code, it looks to me like you should simply be able to publish/promote new Content Views to get these updated values put in all the right places.  However, simply publishing/promoting didn't actually seem to fix everything for me.

Things did start working for me after I republished the metadata of the standalone repositories where the RPMs were uploaded (https://access.redhat.com/solutions/6663481) and then published/promoted the Content Views again.


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