Bug 2109810
| Summary: | Search for string in n-v-r.a format fails for custom packages but not for Red Hat packages | ||
|---|---|---|---|
| Product: | Red Hat Satellite | Reporter: | Eric Nothen <enothen> |
| Component: | Repositories | Assignee: | Pavel Moravec <pmoravec> |
| Status: | CLOSED ERRATA | QA Contact: | Cole Higgins <chiggins> |
| Severity: | medium | Docs Contact: | |
| Priority: | urgent | ||
| Version: | 6.10.7 | CC: | afeferku, ahumbe, apatel, fratto, kgaikwad, mhulan, pmoravec, zhunting |
| Target Milestone: | 6.12.0 | Keywords: | EasyFix, 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: | 2022-11-16 13:34:44 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: | |||
Is this a regression from Satellite 6.9? I can not reproduce it on my satellite-6.10.7-1.el7sat.noarch : # curl -u admin:$PASS "https://$(hostname -f)/katello/api/v2/packages?per_page=10000&page=1&repository_id=9294&search=google-chrome-stable-103.0.5060.134-1.x86_64" {"total":2,"subtotal":1,"page":"1","per_page":"10000","error":null,"search":"google-chrome-stable-103.0.5060.134-1.x86_64","sort":{"by":null,"order":null},"results":[{"id":305245,"pulp_id":"/pulp/api/v3/content/rpm/packages/4ca2bb56-e889-4b55-b7c4-3f4c59f9f701/","name":"google-chrome-stable","version":"103.0.5060.134","release":"1","arch":"x86_64","epoch":"0","summary":"Google Chrome","modular":false,"filename":"google-chrome-stable-103.0.5060.134-1.x86_64.rpm","sourcerpm":"google-chrome-stable-103.0.5060.134-1.src.rpm","checksum":"0cb17f6ed4f421fe2c61e66d6db28dd442c3a5f4fed07629f23cc070d19165ea","nvrea":"google-chrome-stable-103.0.5060.134-1.x86_64","nvra":"google-chrome-stable-103.0.5060.134-1.x86_64","uuid":"/pulp/api/v3/content/rpm/packages/4ca2bb56-e889-4b55-b7c4-3f4c59f9f701/","hosts_available_count":0,"hosts_applicable_count":0}]} # curl -u admin:$PASS "https://$(hostname -f)/katello/api/v2/packages?per_page=10000&page=1&repository_id=9294&search=google-chrome-stable-103.0.5060.134-1" {"total":2,"subtotal":1,"page":"1","per_page":"10000","error":null,"search":"google-chrome-stable-103.0.5060.134-1","sort":{"by":null,"order":null},"results":[{"id":305245,"pulp_id":"/pulp/api/v3/content/rpm/packages/4ca2bb56-e889-4b55-b7c4-3f4c59f9f701/","name":"google-chrome-stable","version":"103.0.5060.134","release":"1","arch":"x86_64","epoch":"0","summary":"Google Chrome","modular":false,"filename":"google-chrome-stable-103.0.5060.134-1.x86_64.rpm","sourcerpm":"google-chrome-stable-103.0.5060.134-1.src.rpm","checksum":"0cb17f6ed4f421fe2c61e66d6db28dd442c3a5f4fed07629f23cc070d19165ea","nvrea":"google-chrome-stable-103.0.5060.134-1.x86_64","nvra":"google-chrome-stable-103.0.5060.134-1.x86_64","uuid":"/pulp/api/v3/content/rpm/packages/4ca2bb56-e889-4b55-b7c4-3f4c59f9f701/","hosts_available_count":0,"hosts_applicable_count":0}]} The repo 9294 is a custom repo with a few other packages (from Red Hat, but still..) I will diagnose more via the support case. Here is the cause:
If RPM filename does not follow NVRA pattern, but source RPM filename follows NVR pattern, then we get this issue. Since this is the key search done:
# search="google-chrome-stable-103.0.5060.134-1"
# su - postgres -c "psql foreman -c \"SELECT name,version,release,arch,epoch,filename,sourcerpm,checksum FROM katello_rpms WHERE ((katello_rpms.name ILIKE '%${search}%' OR katello_rpms.version = '${search}' OR katello_rpms.release = '${search}' OR katello_rpms.arch ILIKE '%${search}%' OR katello_rpms.epoch ILIKE '%${search}%' OR katello_rpms.filename ILIKE '%${search}%' OR katello_rpms.sourcerpm ILIKE '%${search}%' OR katello_rpms.checksum ILIKE '%${search}%'));\""
name | version | release | arch | epoch | filename | sourcerpm | chec
ksum
----------------------+----------------+---------+--------+-------+-----------------------------------------+-----------------------------------------------+---------------------------------
---------------------------------
google-chrome-stable | 103.0.5060.134 | 1 | x86_64 | 0 | google-chrome-stable_current_x86_64.rpm | google-chrome-stable-103.0.5060.134-1.src.rpm | 0cb17f6ed4f421fe2c61e66d6db28dd4
42c3a5f4fed07629f23cc070d19165ea
(1 row)
#
but:
# search="google-chrome-stable-103.0.5060.134-1.x86_64"
# su - postgres -c "psql foreman -c \"SELECT name,version,release,arch,epoch,filename,sourcerpm,checksum FROM katello_rpms WHERE ((katello_rpms.name ILIKE '%${search}%' OR katello_rpms.version = '${search}' OR katello_rpms.release = '${search}' OR katello_rpms.arch ILIKE '%${search}%' OR katello_rpms.epoch ILIKE '%${search}%' OR katello_rpms.filename ILIKE '%${search}%' OR katello_rpms.sourcerpm ILIKE '%${search}%' OR katello_rpms.checksum ILIKE '%${search}%'));\""
name | version | release | arch | epoch | filename | sourcerpm | checksum
------+---------+---------+------+-------+----------+-----------+----------
(0 rows)
#
Katello matches the search (sub)string against:
- name
- version
- release
- arch
- epoch
- filename
- sourcerpm
We shall extend the search to "nvra" attribute, then the search would succeed:
# search="google-chrome-stable-103.0.5060.134-1.x86_64"
# su - postgres -c "psql foreman -c \"SELECT name,version,release,arch,epoch,filename,sourcerpm,checksum FROM katello_rpms WHERE ((katello_rpms.name ILIKE '%${search}%' OR katello_rpms.version = '${search}' OR katello_rpms.release = '${search}' OR katello_rpms.arch ILIKE '%${search}%' OR katello_rpms.epoch ILIKE '%${search}%' OR katello_rpms.filename ILIKE '%${search}%' OR katello_rpms.sourcerpm ILIKE '%${search}%' OR katello_rpms.checksum ILIKE '%${search}%' OR katello_rpms.nvra ILIKE '%${search}%'));\""
name | version | release | arch | epoch | filename | sourcerpm | chec
ksum
----------------------+----------------+---------+--------+-------+-----------------------------------------+-----------------------------------------------+---------------------------------
---------------------------------
google-chrome-stable | 103.0.5060.134 | 1 | x86_64 | 0 | google-chrome-stable_current_x86_64.rpm | google-chrome-stable-103.0.5060.134-1.src.rpm | 0cb17f6ed4f421fe2c61e66d6db28dd4
42c3a5f4fed07629f23cc070d19165ea
(1 row)
#
This should be a trivial fix, I would say.
.. and here is the patch (for Satellite, aply in /opt/theforeman/tfm/root/usr/share/gems/gems/katello-* directory):
--- a/app/models/katello/rpm.rb
+++ b/app/models/katello/rpm.rb
@@ -16,6 +16,7 @@ module Katello
scoped_search :on => :evr, :ext_method => :scoped_search_evr, :only_explicit => true
scoped_search :on => :filename, :complete_value => true
scoped_search :on => :sourcerpm, :complete_value => true
+ scoped_search :on => :nvra, :complete_value => true
scoped_search :on => :modular, :complete_value => true, :only_explicit => true
scoped_search :on => :checksum
Upstream bug assigned to pmoravec Upstream bug assigned to pmoravec (In reply to Brad Buckingham from comment #1) > Is this a regression from Satellite 6.9? I don't have a running Satellite 6.9, but looking at tfm-rubygem-katello-3.18.1.53-1.el7sat.noarch.rpm, it doesn't look like, as it's the same as Pavel fixed on latest: ~~~ $ egrep -n "scoped_search :on" opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.18.1.53/app/models/katello/rpm.rb 11: scoped_search :on => :name, :complete_value => true 12: scoped_search :on => :version, :complete_value => true, :ext_method => :scoped_search_version 13: scoped_search :on => :release, :complete_value => true, :ext_method => :scoped_search_release 14: scoped_search :on => :arch, :complete_value => true 15: scoped_search :on => :epoch, :complete_value => true 16: scoped_search :on => :evr, :ext_method => :scoped_search_evr, :only_explicit => true 17: scoped_search :on => :filename, :complete_value => true 18: scoped_search :on => :sourcerpm, :complete_value => true 19: scoped_search :on => :modular, :complete_value => true, :only_explicit => true 20: scoped_search :on => :checksum ~~~ Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/35290 has been resolved. 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 (Important: Satellite 6.12 Release), 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:8506 |
Description of problem: When searching for a package using name-version-release.architecture format, the search returns the correct results if the package is a provided by Red Hat in an official repository. When doing the same search for a custom package uploaded into a custom product and repository, the search returns no results, but removing the architecture component makes the search work. Version-Release number of selected component (if applicable): Customer reported the issue on Satellite 6.10.7, but I was able to reproduce it on 6.11.0 as well. How reproducible: Always reproducible with a custom rpm. Steps to Reproduce: 1. Create a custom product ~~~ # hammer product create --name Google --organization-id 1 Product created. ~~~ 2. Create a custom repository ~~~ # hammer repository create --content-type yum --name Chrome --product Google Repository created. ~~~ 3. Upload a package to the custom repository ~~~ # hammer repository upload-content --id 245 --path ./google-chrome-stable_current_x86_64.rpm Successfully uploaded file 'google-chrome-stable_current_x86_64.rpm' ~~~ 4. Get the n-v-r.a of the uploaded package ~~~ # rpm -qp --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' ./google-chrome-stable_current_x86_64.rpm 2>/dev/null google-chrome-stable-103.0.5060.134-1.x86_64 ~~~ 5. Search for the package ~~~ # curl -u admin 'https://satellite.keller.lab/katello/api/v2/packages?per_page=10000&page=1&repository_id=245&search=google-chrome-stable-103.0.5060.134-1.x86_64' | python3 -m json.tool Enter host password for user 'admin': % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 184 0 184 0 0 392 0 --:--:-- --:--:-- --:--:-- 392 { "total": 1, "subtotal": 0, "selectable": 0, "page": "1", "per_page": "10000", "error": null, "search": "google-chrome-stable-103.0.5060.134-1.x86_64", "sort": { "by": null, "order": null }, "results": [] } ~~~ Actual results: Search brings no results, but removing the architecture works: ~~~ # curl -u admin 'https://satellite.keller.lab/katello/api/v2/packages?per_page=10000&page=1&repository_id=245&search=google-chrome-stable-103.0.5060.134-1' | python3 -m json.tool Enter host password for user 'admin': % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 848 0 848 0 0 1775 0 --:--:-- --:--:-- --:--:-- 1777 { "total": 1, "subtotal": 1, "selectable": 1, "page": "1", "per_page": "10000", "error": null, "search": "google-chrome-stable-103.0.5060.134-1", "sort": { "by": null, "order": null }, "results": [ { "id": 48234, "pulp_id": "/pulp/api/v3/content/rpm/packages/4e7c2aa5-cd03-48ef-89e8-daad2acde79c/", "name": "google-chrome-stable", "version": "103.0.5060.134", "release": "1", "arch": "x86_64", "epoch": "0", "summary": "Google Chrome", "modular": false, "filename": "google-chrome-stable_current_x86_64.rpm", "sourcerpm": "google-chrome-stable-103.0.5060.134-1.src.rpm", "checksum": "0cb17f6ed4f421fe2c61e66d6db28dd442c3a5f4fed07629f23cc070d19165ea", "nvrea": "google-chrome-stable-103.0.5060.134-1.x86_64", "nvra": "google-chrome-stable-103.0.5060.134-1.x86_64", "uuid": "/pulp/api/v3/content/rpm/packages/4e7c2aa5-cd03-48ef-89e8-daad2acde79c/", "hosts_available_count": 0, "hosts_applicable_count": 0 } ] } ~~~ Expected results: Search would behave the same way as with packages provided by Red Hat repositories, in which including the architecture or not makes no difference. Search for abrt-addon-kerneloops-2.10.9-10.el8.x86_64 brings 1 result: ~~~ # curl -u admin 'https://satellite.keller.lab/katello/api/v2/packages?per_page=10000&page=1&repository_id=131&search=abrt-addon-kerneloops-2.10.9-10.el8.x86_64' | python3 -m json.tool Enter host password for user 'admin': % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 849 0 849 0 0 822 0 --:--:-- 0:00:01 --:--:-- 822 { "total": 13452, "subtotal": 1, "selectable": 1, "page": "1", "per_page": "10000", "error": null, "search": "abrt-addon-kerneloops-2.10.9-10.el8.x86_64", "sort": { "by": null, "order": null }, "results": [ { "id": 36281, "pulp_id": "/pulp/api/v3/content/rpm/packages/b7908aec-2ba2-47bf-93c0-1a73b57e4f00/", "name": "abrt-addon-kerneloops", "version": "2.10.9", "release": "10.el8", "arch": "x86_64", "epoch": "0", "summary": "abrt's kerneloops addon", "modular": false, "filename": "abrt-addon-kerneloops-2.10.9-10.el8.x86_64.rpm", "sourcerpm": "abrt-2.10.9-10.el8.src.rpm", "checksum": "0aedcc7340b780821663dfafe63e49890d22930df4d799a6adbc257be7608195", "nvrea": "abrt-addon-kerneloops-2.10.9-10.el8.x86_64", "nvra": "abrt-addon-kerneloops-2.10.9-10.el8.x86_64", "uuid": "/pulp/api/v3/content/rpm/packages/b7908aec-2ba2-47bf-93c0-1a73b57e4f00/", "hosts_available_count": 0, "hosts_applicable_count": 0 } ] } ~~~ Search for abrt-addon-kerneloops-2.10.9-10.el8 also brings one result: ~~~ # curl -u admin 'https://satellite.keller.lab/katello/api/v2/packages?per_page=10000&page=1&repository_id=131&search=abrt-addon-kerneloops-2.10.9-10.el8' | python3 -m json.tool Enter host password for user 'admin': % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 842 0 842 0 0 821 0 --:--:-- 0:00:01 --:--:-- 822 { "total": 13452, "subtotal": 1, "selectable": 1, "page": "1", "per_page": "10000", "error": null, "search": "abrt-addon-kerneloops-2.10.9-10.el8", "sort": { "by": null, "order": null }, "results": [ { "id": 36281, "pulp_id": "/pulp/api/v3/content/rpm/packages/b7908aec-2ba2-47bf-93c0-1a73b57e4f00/", "name": "abrt-addon-kerneloops", "version": "2.10.9", "release": "10.el8", "arch": "x86_64", "epoch": "0", "summary": "abrt's kerneloops addon", "modular": false, "filename": "abrt-addon-kerneloops-2.10.9-10.el8.x86_64.rpm", "sourcerpm": "abrt-2.10.9-10.el8.src.rpm", "checksum": "0aedcc7340b780821663dfafe63e49890d22930df4d799a6adbc257be7608195", "nvrea": "abrt-addon-kerneloops-2.10.9-10.el8.x86_64", "nvra": "abrt-addon-kerneloops-2.10.9-10.el8.x86_64", "uuid": "/pulp/api/v3/content/rpm/packages/b7908aec-2ba2-47bf-93c0-1a73b57e4f00/", "hosts_available_count": 0, "hosts_applicable_count": 0 } ] } ~~~