Bug 903557

Summary: Extra packages counts and lists are wrong in spacewalk 1.8
Product: [Community] Spacewalk Reporter: Stéphane Gaubert <s.gaubert>
Component: WebUIAssignee: Milan Zazrivec <mzazrivec>
Status: CLOSED CURRENTRELEASE QA Contact: Red Hat Satellite QA List <satellite-qa-list>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 1.8CC: mzazrivec
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-03-06 13:34:13 EST Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On:    
Bug Blocks: 917805    

Description Stéphane Gaubert 2013-01-24 04:49:39 EST
Description of problem:
Spacewalk 1.8 displays installed packages belonging to a channel for which system is subscribed as extra packages.

Version-Release number of selected component (if applicable):
1.8

How reproducible:
Create 2 channels containing different packages with the same name, version and architecture. For instance, I discovered this bug by creating a channel for CentOS 6 x86_64 and RHEL 6 x86_64.

Steps to Reproduce:
1.
2.
3.
  
Actual results:
A system subscribed to one of the 2 channels will report every installed packages having an homonym in an other channel as extra although they belong to a channel for witch the system is subscribed.

Expected results:
The extra package list should not report packages that belong to a channel on which a system is subscribed.

Additional info:

The 2 SQL requests used to count and list the number of extra packages are incorrect. The problem lies in 'left outer join rhnPackage p on (sp.name_id = p.name_id and sp.evr_id = p.evr_id and sp.package_arch_id = p.package_arch_id)'.

Here are proposed replacement SQL requests for packages_in_errata and packages_in_tmp_errata in java/code/src/com/redhat/rhn/common/db/datasource/xml/Package_queries.xml that seem to give the correct result :

<mode name="extra_packages_systems_count"
      class="com.redhat.rhn.frontend.dto.SystemOverview">
  <query params="userid, orgid">
select s.id as id,
       s.name as name,
       1 as selectable,
       count(sp.name_id) as extra_pkg_count
  from rhnServer s
       join rhnUserServerPerms usp on (usp.server_id = s.id and
                                       usp.user_id = :userid)
       join rhnServerPackage sp on (s.id = sp.server_id)
        left outer join (select sc.server_id, cp.package_id, p.name_id, p.evr_id, p.package_arch_id
                           from rhnPackage p, rhnServerChannel sc
                                join rhnChannelPackage cp on (sc.channel_id = cp.channel_id) where cp.package_id = p.id
                        ) scp on (scp.server_id = sp.server_id and
				  sp.name_id = scp.name_id and
                                  sp.evr_id = scp.evr_id and
                                  sp.package_arch_id = scp.package_arch_id)
 where scp.package_id is null and
       s.org_id = :orgid
 group by s.name, s.id
 order by name, id
  </query>
  <elaborator name="system_overview" />
  <elaborator name="entitlements" />
  <elaborator name="is_virtual_guest" />
  <elaborator name="is_virtual_host" />
</mode>

<mode name="extra_packages_for_system" class="com.redhat.rhn.frontend.dto.PackageListItem">
  <query params="serverid">
select scp.package_id,
       pn.id || '|' || pe.id || '|' || pa.id as id_combo,
       pn.name || '-' || pe.version || '-' || pe.release as nvre,
       pn.name || '-' || evr_t_as_vre_simple(pe.evr) || '.' || pa.label as nvrea,
       pn.name as name,
       pe.version as version,
       pe.release as release,
       pe.epoch as epoch,
       pn.id as name_id,
       pe.id as evr_id,
       pa.label as arch,
       sp.installTime
  from rhnServerPackage sp
        left outer join (select sc.server_id, cp.package_id, p.name_id, p.evr_id, p.package_arch_id
                           from rhnPackage p, rhnServerChannel sc
                                join rhnChannelPackage cp on (sc.channel_id = cp.channel_id) where cp.package_id = p.id
                        ) scp on (scp.server_id = sp.server_id and
				  sp.name_id = scp.name_id and
                                  sp.evr_id = scp.evr_id and
                                  sp.package_arch_id = scp.package_arch_id)
       left outer join rhnPackageName pn on (pn.id = sp.name_id)
       left outer join rhnPackageArch pa on (pa.id = sp.package_arch_id)
       left outer join rhnPackageEvr pe on (pe.id = sp.evr_id)
 where sp.server_id = :serverid and
       (scp.package_id is null)
 order by nvre
  </query>
</mode>
Comment 1 Stéphane Gaubert 2013-01-24 04:52:12 EST
extra_packages_systems_count belongs to java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
Comment 2 Milan Zazrivec 2013-02-01 10:03:30 EST
Fixed in spacewalk.git master: 1d3c5cd2a566d6ed5a273e64e2b395ce7c6d144a
Comment 3 Stephen Herr 2013-03-01 12:06:52 EST
Marking bug as ON_QA since tonight's build of Spacewalk nightly is a release candidate for Spacewalk 1.9.
Comment 4 Stephen Herr 2013-03-06 13:34:13 EST
Spacewalk 1.9 has been released.

https://fedorahosted.org/spacewalk/wiki/ReleaseNotes19