Bug 616267

Summary: system.ListPackages returns empty set for pre-RHEL 4.8 systems due to null package_arch_id
Product: Red Hat Satellite 5 Reporter: Xixi <xdmoon>
Component: ServerAssignee: Justin Sherrill <jsherril>
Status: CLOSED CURRENTRELEASE QA Contact: Michael Mráka <mmraka>
Severity: medium Docs Contact:
Priority: medium    
Version: 530CC: cperry, jhutar, mmraka, pnovotny, samuel.kielek, xdmoon
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2010-10-28 14:53:11 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:
Bug Depends On:    
Bug Blocks: 487678, 608754    

Description Xixi 2010-07-20 00:30:30 UTC
Description of problem:
For systems with OS older than RHEL 4.8 (such as RHEL 3 and older RHEL 4.x), the RHN API call system.listPackages returns an empty array.  This is due to the system profile having null package_arch_ids - see bottom for more background info.

Version-Release number of selected component (if applicable):
Red Hat Network (RHN) Satellite 5.3.0

How reproducible:
Always.

Steps to Reproduce:
1. Register a RHEL 3 or RHEL 4 (4.7 or earlier) system to 5.3 Satellite and up2date -p to update package profile.  Notice the "not specified" under architecture listing under System Details -> Software -> List packages.
2. Call system.listPackages API call on the system.

Actual results:
Empty array returned instead of array of installed pkgs.

Expected results:
Returns array of installed pkgs.

Additional info:
This is caused by an old bug where rhn client doesn't sending package architecture information during updates, which was fixed in RHEL 4.8 and RHEL 5. The bug was such that during initial registration, package arch info is sent to the Satellite and populated, however a profile refresh (such as "up2date -p" or installing pkgs via activation keys) will refresh package information minus the architecture, resulting in null package_arch_ids. This is why customer is only seeing older (RHEL release wise) systems being affected, and pkg/profile refresh doesn't help (in fact that's when they'll end up with null package arch ids).

The fix would be to update the clients to get the bugfix, and a workaround would be to re-register system, but do not use any activation keys to install packages, or schedule any package/profile refreshes.
(part of this came from https://bugzilla.redhat.com/show_bug.cgi?id=568958#c5 which is caused by the same thing)

Comment 1 Xixi 2010-07-20 00:32:05 UTC
As seen in the data query below, the API call returns empty b/c the underlying data query joins by package_arch_id, which is null for affected clients.

spacewalk-java-0.5.44/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java
...
    public Object[] listPackages(String sessionKey, Integer sid) throws FaultException {
        // Get the logged in user and server
        User loggedInUser = getLoggedInUser(sessionKey);
        Server server = lookupServer(loggedInUser, sid);

        DataResult dr = SystemManager.installedPackages(server.getId());
        return dr.toArray();
    }
...

spacewalk-java-0.5.44/code/src/com/redhat/rhn/manager/system/SystemManager.java
...
    public static DataResult installedPackages(Long sid) {
        SelectMode m = ModeFactory.getMode("System_queries", "system_installed_packages",
                                           Map.class);
        Map params = new HashMap();
        params.put("sid", sid);
        return m.execute(params);
    }
...

spacewalk-java-0.5.44/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
...
<mode name="system_installed_packages">
  <query params="sid">
SELECT PN.name,
       PE.version,
       PE.release,
       NVL(PE.epoch, ' ') as epoch,
       PA.name as arch
  FROM rhnPackageName PN, rhnPackageEVR PE, rhnServerPackage SP, rhnPackageArch PA
 WHERE SP.server_id = :sid
   AND PN.id = SP.name_id
   AND PE.id = SP.evr_id
   AND PA.id = SP.package_arch_id
ORDER BY PN.name, PE.evr
  </query>
</mode>
...

Comment 3 Justin Sherrill 2010-07-26 19:28:48 UTC
Fixed in spacewalk master for satellite 5.4

5c8acab5438496c77ea1dda2c4e2ec02e5c60efd

Comment 4 Michael Mráka 2010-10-06 14:17:16 UTC
Verified.

on client
# systemListPackages.py
[{'release': '3', 'epoch': ' ', 'version': '3.15.2', 'arch': 'AMD64', 'name': 'MAKEDEV'}, {'release': '34.4', 'epoch': ' ', 'version': '2.85', 'arch': 'AMD64', 'name': 'SysVinit'}, {'release': '32', 'epoch': ' ', 'version': '2.3', 'arch': 'AMD64', 'name': 'anacron'}, {'release': '4.EL4', 'epoch': '12', 'version': '0.50.5', 'arch': 'AMD64', 'name': 'aspell'}, {'release': '11', 'epoch': '50', 'version': '0.51', 'arch': 'AMD64', 'name': 'aspell-en'},
...

on server
# rpm -q spacewalk-java
spacewalk-java-1.2.39-26.el5sat

Comment 7 Clifford Perry 2010-10-28 14:48:23 UTC
The 5.4.0 RHN Satellite and RHN Proxy release has occurred. This issue has been resolved with this release. 


RHEA-2010:0801 - RHN Satellite Server 5.4.0 Upgrade
https://rhn.redhat.com/rhn/errata/details/Details.do?eid=10332

RHEA-2010:0803 - RHN Tools enhancement update
https://rhn.redhat.com/rhn/errata/details/Details.do?eid=10333

RHEA-2010:0802 - RHN Proxy Server 5.4.0 bug fix update
https://rhn.redhat.com/rhn/errata/details/Details.do?eid=10334

RHEA-2010:0800 - RHN Satellite Server 5.4.0
https://rhn.redhat.com/rhn/errata/details/Details.do?eid=10335

Docs are available:

http://docs.redhat.com/docs/en-US/Red_Hat_Network_Satellite/index.html 

Regards,
Clifford