Bug 619270

Summary: livecd-creator imports Yum modules, ctrl-c during package transaction exits without letting livecd-creator cleanup properly
Product: [Fedora] Fedora Reporter: Jasper O'neal Hartline <Jasper.Hartline>
Component: yumAssignee: Packaging Maintenance Team <packaging-team-maint>
Status: CLOSED EOL QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 19CC: ffesti, james.antill, mads, Marc.Herbert+rhzilla, maxamillion, pmatilai, tim.lauridsen
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: 2015-02-17 13:18:32 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:

Description Jasper O'neal Hartline 2010-07-29 06:28:14 UTC
Description of problem:

When running livecd-creator and during a package transaction which is in Yum code in runTransaction(), after pressing CTRL-C the application exits immediately without allowing livecd-creator to finish it's job, like being able to cleanup.

Relevant block of livecd-creator where the transaction is at:
    def runInstall(self):
        os.environ["HOME"] = "/"
        try:
            (res, resmsg) = self.buildTransaction()
        except yum.Errors.RepoError, e:
            raise CreatorError("Unable to download from repo : %s" %(e,))
        if res != 2:
            raise CreatorError("Failed to build transaction : %s" % str.join("\n", resmsg))

        dlpkgs = map(lambda x: x.po, filter(lambda txmbr: txmbr.ts_state in ("i", "u"), self.tsInfo.getMembers()))
        self.downloadPkgs(dlpkgs)
        # FIXME: sigcheck?

        self.initActionTs()
        self.populateTs(keepold=0)
        deps = self.ts.check()
        if len(deps) != 0:
            raise CreatorError("Dependency check failed!")
        rc = self.ts.order()
        if rc != 0:
            raise CreatorError("ordering packages for installation failed!")

        # FIXME: callback should be refactored a little in yum 
        sys.path.append('/usr/share/yum-cli')
        import callback
        cb = callback.RPMInstallCallback()
        cb.tsInfo = self.tsInfo
        cb.filelog = False
        ret = self.runTransaction(cb)
        print ""
        self._cleanupRpmdbLocks(self.conf.installroot)
        return ret


Here is output from the shell, ctrl-C is pressed during the hash printing of package glibc where it then prints a C and exits.

Need some way to not exit so we can cleanup.

[root@localhost tmp]# livecd-creator -c livecd.ks -f testing
mke2fs 1.41.12 (17-May-2010)
Filesystem label=_testing
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
262144 inodes, 1048576 blocks
10485 blocks (1.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1073741824
32 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736

Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 25 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
tune2fs 1.41.12 (17-May-2010)
Setting maximal mount count to -1
Setting interval between checks to 0 seconds
Retrieving file:///pub/repo/rawhide/repodata/repomd.xml ...OK
Retrieving file:///pub/repo/rawhide/repodata/8a0b976967886f5a4abe3710a0b5b2b00e771e5ffa2cb16472e908ad19906946-primary.sqlite.bz2 ...OK
Retrieving file:///pub/repo/rawhide/repodata/2d85828b5fbb0a86822c702ba615da8a96bd8d805a81272732971b7bbd0e9f15-comps-rawhide.xml.gz ...OK
  Installing: setup                        ##################### [  1/383] 
  Installing: filesystem                   ##################### [  2/383] 
  Installing: fedora-release-rawhide       ##################### [  3/383] 
  Installing: fedora-release               ##################### [  4/383] 
warning: basesystem-10.0-3.noarch: Header V3 RSA/SHA256 Signature, key ID e8e40fde: NOKEY
  Installing: basesystem                   ##################### [  5/383] 
  Installing: kbd-misc                     ##################### [  6/383] 
  Installing: tzdata                       ##################### [  7/383] 
  Installing: comps-extras                 ##################### [  8/383] 
  Installing: dmz-cursor-themes            ##################### [  9/383] 
  Installing: xkeyboard-config             ##################### [ 10/383] 
  Installing: libX11-common                ##################### [ 11/383] 
  Installing: mobile-broadband-provider-in ##################### [ 12/383] 
  Installing: ncurses-base                 ##################### [ 13/383] 
  Installing: ca-certificates              ##################### [ 14/383] 
  Installing: xml-common                   ##################### [ 15/383] 
  Installing: control-center-filesystem    ##################### [ 16/383] 
  Installing: libgcc                       ##################### [ 17/383] 
  Installing: rootfiles                    ##################### [ 18/383] 
  Installing: bash                         ##################### [ 19/383] 
  Installing: glibc-common                 ##################### [ 20/383] 
  Installing: nss-softokn-freebl           ##################### [ 21/383] 
  Installing: glibc                        ##################### [ 22/383] C
/var/tmp/imgcreate-1ROdwu/install_root/var/lib/rpm: No such file or directory
[root@localhost tmp]# losetup -a
/dev/loop0: [0802]:3933539 (/var/tmp/imgcreate-09UmNB/tmp-0ThwfQ/ext3fs.img)
/dev/loop1: [0802]:3965104 (/var/tmp/imgcreate-5P42UA/tmp-oAV5Oy/ext3fs.img)
/dev/loop2: [0802]:3990626 (/var/tmp/imgcreate-1ROdwu/tmp-oZdqvI/ext3fs.img)
[root@localhost tmp]# mount | grep install_root
/dev/loop0 on /var/tmp/imgcreate-09UmNB/install_root type ext4 (rw)
/sys on /var/tmp/imgcreate-09UmNB/install_root/sys type none (rw,bind)
/proc on /var/tmp/imgcreate-09UmNB/install_root/proc type none (rw,bind)
/dev/pts on /var/tmp/imgcreate-09UmNB/install_root/dev/pts type none (rw,bind)
/dev/shm on /var/tmp/imgcreate-09UmNB/install_root/dev/shm type none (rw,bind)
/var/tmp/imgcreate-09UmNB/yum-cache on /var/tmp/imgcreate-09UmNB/install_root/var/cache/yum type none (rw,bind)
/dev/loop2 on /var/tmp/imgcreate-1ROdwu/install_root type ext4 (rw)
/sys on /var/tmp/imgcreate-1ROdwu/install_root/sys type none (rw,bind)
/proc on /var/tmp/imgcreate-1ROdwu/install_root/proc type none (rw,bind)
/dev/pts on /var/tmp/imgcreate-1ROdwu/install_root/dev/pts type none (rw,bind)
/dev/shm on /var/tmp/imgcreate-1ROdwu/install_root/dev/shm type none (rw,bind)
/var/tmp/imgcreate-1ROdwu/yum-cache on /var/tmp/imgcreate-1ROdwu/install_root/var/cache/yum type none (rw,bind)
[root@localhost tmp]#

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


How reproducible:


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:

Comment 1 Jasper O'neal Hartline 2010-07-30 00:52:57 UTC
It seems rpmUtils/miscutils.py: checkSignals() is always trapping SIGINT.
I've found the only way to catch CTRL-C/KeyboardInterrupt/SIGINT from the user during runTransaction() is to initialize a signal handler right before runTransaction() happens inside of def install() in yuminst.py of livecd-tools/python-imgcreate.

I am looking at the rest of livecd-tools/python-imgcreate and it appears that there are methods to clean up but this signal handling by rpm-python wasn't forseen, and instead appears as if we will always rely on the fact that runTransaction() completes successfully, which in some cases it won't. 

Any suggestions on how I should handle this from Yum's point of view?
The fact is livecd-creator cannot cleanup properly, and I should work around this or have Yum/rpm-python not handle the signal but this seems incorrect.
Does initializing a signal handler before runTransaction() seem more reasonable, and within it do what must happen to cleanup despite the already existing methods for unmounting and cleanup which was written in creator.py?

Comment 2 MarcH 2010-07-30 08:54:19 UTC
FWIW here is my "make clean" target to workaround this problem:

LIVECD_TMP ?= /var/tmp
clean:
	- mount | grep "${LIVECD_TMP}"/imgcreate | awk '{print $$3}' | tac | \
	         while read mpoint; do sudo umount $$mpoint; done
	for lo in $$(sudo losetup -a |  grep "${LIVECD_TMP}"/imgcreate | cut -d: -f1); do \
	               sudo losetup -d $$lo; done
	- sudo ${RM} -r  "${LIVECD_TMP}"/imgcreate-*

Comment 3 Fedora End Of Life 2013-04-03 19:03:16 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 19 development cycle.
Changing version to '19'.

(As we did not run this process for some time, it could affect also pre-Fedora 19 development
cycle bugs. We are very sorry. It will help us with cleanup during Fedora 19 End Of Life. Thank you.)

More information and reason for this action is here:
https://fedoraproject.org/wiki/BugZappers/HouseKeeping/Fedora19

Comment 4 Vladimir 2013-04-28 23:42:50 UTC
Trying to make a LiveCD:

livecd-creator -c kde-19.ks --releasever=19 -t /home/vk/tmp --cache=/home/vk/tmp/19 --verbose 2>&1 | tee kde-19.log

LiveCD-creator of the work can not be done in Fedora 19, but well done on the same machine in Fedora 18

1. log in Fedora 19:  http://fpaste.org/9059/13671906/
2. log in Fedora 18:  http://fpaste.org/9064/36719241/

thank you

Comment 5 Vladimir 2013-07-27 18:59:02 UTC
Making a 32-bit spin ISO on a 64-bit machine:

# setarch i386 livecd-creator -c 368.ks --releasever=1 -t /home/vk/tmp --cache=/home/vk/tmp/19 --verbose 2>&1 | tee 368.log

Operation stops with error output:

Losetup remove /dev/loop1
BDB2053 Freeing read locks for locker 0x65: 4247/140581645281280
BDB2053 Freeing read locks for locker 0x66: 4247/140581645281280
BDB2053 Freeing read locks for locker 0x67: 4247/140581645281280
BDB2053 Freeing read locks for locker 0x68: 4247/140581645281280
Traceback (most recent call last):
  File "/bin/livecd-creator", line 237, in <module>
    sys.exit(main())
  File "/bin/livecd-creator", line 227, in main
    logging.error(u"Error creating Live CD : %s" % e)
  File "/usr/lib/python2.7/site-packages/imgcreate/errors.py", line 45, in __unicode__
    return unicode(self.message)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 34: ordinal not in range(128)

thank you

Comment 6 Vladimir 2013-08-02 22:15:52 UTC
I'm sorry, I was not paying attention:
 "--releasever=1 " = "--releasever=19"

I'm sorry

Comment 7 Fedora End Of Life 2015-01-09 16:17:13 UTC
This message is a notice that Fedora 19 is now at end of life. Fedora 
has stopped maintaining and issuing updates for Fedora 19. It is 
Fedora's policy to close all bug reports from releases that are no 
longer maintained. Approximately 4 (four) weeks from now this bug will
be closed as EOL if it remains open with a Fedora 'version' of '19'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 19 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 8 Fedora End Of Life 2015-02-17 13:18:32 UTC
Fedora 19 changed to end-of-life (EOL) status on 2015-01-06. Fedora 19 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.