Bug 1142535

Summary: [regression] "rlJournalStart: Failed to initialize the journal. Bailing out..." on RHEL5
Product: [Fedora] Fedora EPEL Reporter: Jun'ichi NOMURA <junichi.nomura>
Component: beakerlibAssignee: Dalibor Pospíšil <dapospis>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: el5CC: aigao, asaha, dapospis, dcallagh, kueda, mcsontos, ncoghlan, pmuller, psplicha, qa-errata-list, tatsu-ab1
Target Milestone: ---Keywords: Patch
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: beakerlib-1.10-1.el5 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-12-17 05:34:54 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:
Attachments:
Description Flags
a naive workaround patch
none
patch
none
patch none

Description Jun'ichi NOMURA 2014-09-17 01:23:18 UTC
Description of problem:
  rlJournalStart fails to initialize journal on RHEL5.
  As a result, test programs which use beakerlib fail.

Version-Release number of selected component (if applicable):
  beah-0.7.6-1.el5
  beakerlib-1.9-4.el5
  rpm-python-4.4.2.3-34.el5

How reproducible:
  Always

Steps to Reproduce:
  Run this from shell:
    . /usr/share/beakerlib/beakerlib.sh
    rlJournalStart

Actual results:
  # . /usr/share/beakerlib/beakerlib.sh 
  # rlJournalStart
  Traceback (most recent call last):
    File "/usr/bin/beakerlib-journalling", line 861, in ?
      sys.exit(main())
    File "/usr/bin/beakerlib-journalling", line 794, in main
      return Journal.initializeJournal(options.test, package)
    File "/usr/bin/beakerlib-journalling", line 397, in initializeJournal
      beakerlib_redhat_rpm = mi.next()
  StopIteration
  rlJournalStart: Failed to initialize the journal. Bailing out...

Expected results:
  rlJournalStart should not crash.

Additional info:
  Package "beakerlib-redhat" does not exist in our lab.

  The problem wasn't observed on newer distros (RHEL6, RHEL7).
  So this could be due to behavior change in rpm-python that the harness has to care about.

  # python
  Python 2.4.3 (#1, Oct 23 2012, 22:02:41) 
  [GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import rpm
  >>> ts = rpm.ts()
  >>> mi = ts.dbMatch("name", "beakerlib")
  >>> print mi
  <rpm.mi object at 0x2b06cc618300>
  >>> print "%(name)s-%(version)s-%(release)s " % mi.next()
  beakerlib-1.9-4.el5 
  >>> mi = ts.dbMatch("name", "beakerlib-redhat")
  >>> print mi
  <rpm.mi object at 0x2b06cc6182d8>
  >>> print "%(name)s-%(version)s-%(release)s " % mi.next()
  Traceback (most recent call last):
    File "<stdin>", line 1, in ?
  StopIteration

Comment 1 Jun'ichi NOMURA 2014-09-17 05:15:41 UTC
Created attachment 938333 [details]
a naive workaround patch

Just in case, attached is a naive workaround.

# . /usr/share/beakerlib/beakerlib.sh
# rlJournalStart
# rlJournalPrint
...
	<beakerlib_rpm>
		beakerlib-1.9-4.el5 
	</beakerlib_rpm>
	<beakerlib_redhat_rpm>
		not installed
	</beakerlib_redhat_rpm>
...

Comment 2 Dan Callaghan 2014-09-19 06:36:35 UTC
(In reply to Jun'ichi NOMURA from comment #0)
>   The problem wasn't observed on newer distros (RHEL6, RHEL7).
>   So this could be due to behavior change in rpm-python that the harness has
> to care about.

Yes, it looks like the rpm.mi type grew bool coercion in rpm 4.8.1 (RHEL6+):

http://rpm.org/gitweb?p=rpm.git;a=commitdiff;h=9a93c9364d15cb569c6c9492be9ed992d28a3fc3

Easiest fix would be to just check the len() of the rpm.mi objects instead of relying on bool coercion. Patch to come.

Comment 3 Dan Callaghan 2014-09-19 06:37:35 UTC
Created attachment 939101 [details]
patch

Haven't verified this patch yet.

Comment 4 Dan Callaghan 2014-09-19 07:00:41 UTC
Actually I just found this patch which changes a len() to .count(), I guess because some (even older?) versions of RPM don't support len() on rpm.mi either?

https://git.fedorahosted.org/cgit/beakerlib.git/commit/?id=f38e47bd18676b87db9aecbe878954b6896b569a

Comment 5 Dan Callaghan 2014-09-19 07:03:34 UTC
rpm.mi only added len() support in RPM 4.8.0 as well.

http://rpm.org/gitweb?p=rpm.git;a=commitdiff;h=909982b1b5d2bccbf28ecfb38064ab86e09d4523

Comment 6 Dan Callaghan 2014-09-19 07:22:02 UTC
Created attachment 939109 [details]
patch

Second attempt at a patch, still haven't verified it.

Corresponding test package is here:
https://fedorapeople.org/~dcallagh/beakerlib-1.9-4.el5.bz1142535test.noarch.rpm

Comment 7 Jun'ichi NOMURA 2014-09-19 08:27:23 UTC
(In reply to Dan Callaghan from comment #6)
> Corresponding test package is here:
> https://fedorapeople.org/~dcallagh/beakerlib-1.9-4.el5.bz1142535test.noarch.
> rpm

Thanks, I tried the test package and it works for me.

Except from journal.xml:
  <BEAKER_TEST>
    <test_id>1155290</test_id>
    <package>distribution</package>
    <pkgnotinstalled>distribution</pkgnotinstalled>
    <beakerlib_rpm>beakerlib-1.9-4.el5.bz1142535test </beakerlib_rpm>
    <beakerlib_redhat_rpm>not installed</beakerlib_redhat_rpm>
    ..

Comment 9 Fedora Update System 2014-10-06 15:05:31 UTC
beakerlib-1.9-5.el5 has been submitted as an update for Fedora EPEL 5.
https://admin.fedoraproject.org/updates/beakerlib-1.9-5.el5

Comment 10 Fedora Update System 2014-10-08 18:04:17 UTC
beakerlib-1.9-6.el5 has been submitted as an update for Fedora EPEL 5.
https://admin.fedoraproject.org/updates/beakerlib-1.9-6.el5

Comment 11 Fedora Update System 2014-12-01 15:54:07 UTC
beakerlib-1.10-1.el5 has been submitted as an update for Fedora EPEL 5.
https://admin.fedoraproject.org/updates/beakerlib-1.10-1.el5

Comment 12 Fedora Update System 2014-12-17 05:34:54 UTC
beakerlib-1.10-1.el5 has been pushed to the Fedora EPEL 5 stable repository.  If problems still persist, please make note of it in this bug report.