Bug 253524 - upgrades with empty errata cause tracebacks
Summary: upgrades with empty errata cause tracebacks
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Satellite 5
Classification: Red Hat
Component: Upgrades
Version: unspecified
Hardware: All
OS: Linux
high
high
Target Milestone: ---
Assignee: Jan Pazdziora
QA Contact: Preethi Thomas
URL:
Whiteboard:
Depends On:
Blocks: 248635
TreeView+ depends on / blocked
 
Reported: 2007-08-20 12:46 UTC by Martin Poole
Modified: 2018-10-19 23:11 UTC (History)
1 user (show)

Fixed In Version: sat510
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2008-04-02 21:41:19 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
sql to diagnose empty errata (140 bytes, text/plain)
2007-08-20 12:51 UTC, Martin Poole
no flags Details
Traceback from Satellite 5.1.0 (3.40 KB, text/plain)
2008-01-10 15:57 UTC, Jan Pazdziora
no flags Details

Description Martin Poole 2007-08-20 12:46:20 UTC
Description of problem:

When upgrading a satellite < 4.2 to 4.2 or later if there are errata associated
with channels with no associated packages and these channels are subsequently
applied to RHEL5 machines those machines will then fail all further updates
until packages are applied to the errata or the channel is disassociated with
the machine.

Steps to Reproduce:
1. on pre 4.2 sat create errata associated with non-RHEL channel without packages
2. upgrade to 4.2 or later
3. associate a rhel5 machine with the channel and attempt to update.
  
Actual results:


Exception Handler Information
Traceback (most recent call last):
 File "/usr/share/rhn/server/apacheRequest.py", line 108, in call_function
   response = apply(func, params)
 File "/usr/share/rhn/server/rhnRepository.py", line 169, in repodata
   output = repo.get_repomd_file()
 File "/usr/share/rhn/server/repomd/repository.py", line 299, in get_repomd_file
   self.repository.get_updateinfo_xml_file(),
 File "/usr/share/rhn/server/repomd/repository.py", line 90, in
get_updateinfo_xml_file
   viewobj.write_updateinfo()
 File "/usr/share/rhn/server/repomd/view.py", line 287, in write_updateinfo
   for erratum in self.channel.errata:
 File "/usr/share/rhn/server/repomd/mapper.py", line 102, in _erratum_generator
   erratum = self.erratum_mapper.get_erratum(erratum_id[0])
 File "/usr/share/rhn/server/repomd/mapper.py", line 423, in get_erratum
   package = self.package_mapper.get_package(package_id)
 File "/usr/share/rhn/server/repomd/mapper.py", line 129, in get_package
   last_modified = str(self.mapper.last_modified(package_id))
 File "/usr/share/rhn/server/repomd/mapper.py", line 268, in last_modified
   return self.last_modified_sql.fetchone()[0]
TypeError: unsubscriptable object


Expected results:

no error.

Additional info:

Comment 1 Martin Poole 2007-08-20 12:51:24 UTC
Created attachment 161869 [details]
sql to diagnose empty errata

Comment 2 Clifford Perry 2007-08-20 15:48:04 UTC
SQL from attachment is:

select id,advisory,advisory_name from rhnErrata re
    where (select count(*) from rhnErrataPackage rep where rep.errata_id =
re.id) = 0;

I am not sure when/where I could add this type of check in the upgrade process.
But it is worth looking at for Sat 5.1 upgrades. 

There is no IT with this, so I am wondering if you can hit this with
pre-upgraded systems and current code base, once upgraded, prevents this issue
from occuring. 

Cliff. 

Comment 4 Jan Pazdziora 2008-01-04 09:34:25 UTC
(In reply to comment #3)
> Flags are all set but status is still NEW. Has this been fixed yet ?

No. It is in my queue.

Comment 5 Jan Pazdziora 2008-01-10 14:22:33 UTC
I've took freshly baked 5.1.0 Satellite (no upgrade), created custom channel,
put packages into it, put erratas into it, then deleted those packages.

The select from comment 2 returns some records for me, and repomd data get
generated without problem. So it looks like this select does not describe the
situation when the repomd generation would fail.

Of course, the 5.1.0 code might have changed from 4.2 so what used to fail on
4.2 does not fail on 5.1.0 anymore.

Comment 6 Jan Pazdziora 2008-01-10 14:37:09 UTC
Hmmm, but those erratas still have those packages in the channel I've cloned
them from ... So this was not a good test.

Comment 7 Jan Pazdziora 2008-01-10 15:56:07 UTC
The problem is not updates-related. I was able to reproduce it solely on
Satellite 5.1.0.

The problem lies in the fact that if a package is deleted from the system, the
errata cache record (like /var/cache/rhn/repomd-errata/1194) never gets updated.
When the code of

 File "/usr/share/rhn/server/repomd/mapper.py", line 423, in get_erratum
   package = self.package_mapper.get_package(package_id)

is executed within this method

    def get_erratum(self, erratum_id):
        """
        Load the erratum with id erratum_id. 
        
        Load from the cache, if it is new enough. If not, fall back to the
        provided mapper.
        """
        erratum_id = str(erratum_id)

        last_modified = str(self.mapper.last_modified(erratum_id))
        last_modified = re.sub(" ", "", last_modified)
        last_modified = re.sub(":", "", last_modified)
        last_modified = re.sub("-", "", last_modified)

        cache_key = "repomd-errata/" + erratum_id
        if self.cache.has_key(cache_key, last_modified):
            erratum = self.cache.get(cache_key)
            for package_id in erratum.package_ids:
                package = self.package_mapper.get_package(package_id)
                erratum.packages.append(package)
        else:
            erratum = self.mapper.get_erratum(erratum_id)

            tmp_packages = erratum.packages
            erratum.packages = []
            self.cache.set(cache_key, erratum, last_modified)
            erratum.packages = tmp_packages

        return erratum

it fetches the erratum.package_ids from the cache and then tries to fetch the
package from the database. And since the package is no longer in the database,
it fails.

Comment 8 Jan Pazdziora 2008-01-10 15:57:21 UTC
Created attachment 291294 [details]
Traceback from Satellite 5.1.0

This is an up-to-date traceback from the latest Satellite.

Comment 10 Jan Pazdziora 2008-01-11 16:26:21 UTC
Sending        schema/rhnsat/tables/rhnErrataPackage_triggers.sql
Transmitting file data .
Committed revision 135606.

Sending        schema/satellite-upgrade/satellite-5.0-to-5.1.sql
Transmitting file data .
Committed revision 135607.



Comment 11 Jan Pazdziora 2008-01-14 12:27:30 UTC
For the situation originally reported and reflected in the summary of this
bugzilla, namely that tracebacks start to appear after upgrade of the Satellite,
I strongly suspect that the OP did not run

rm -fr /var/cache/rhn/*

as suggested by /etc/sysconfig/rhn/satellite-upgrade/README.

Comment 12 Jan Pazdziora 2008-01-14 12:28:37 UTC
With Satellite ISO 5.1.0-47 available, and more importantly, with
http://barn.rhndev.redhat.com/repo/repository/rhn-upgrade/rhn-upgrade-5.1.0-5.noarch.rpm
available, moving ON_QA.

Comment 17 Brandon Perkins 2008-04-02 21:41:19 UTC
Satellite 5.1.0 Upgrades (sat/proxy) for 5.1 Sat GA so Closed for Current Release.


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