Bug 1483524

Summary: urlgrabber on RHEL 6 raises KeyboardInterrupt if no space left on device
Product: Red Hat Enterprise Linux 6 Reporter: Gennadii Altukhov <galtukho>
Component: python-urlgrabberAssignee: Valentina Mukhamedzhanova <vmukhame>
Status: CLOSED WONTFIX QA Contact: BaseOS QE - Apps <qe-baseos-apps>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.10CC: packaging-team-maint, toki
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-12-06 11:45:02 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:
Bug Depends On:    
Bug Blocks: 1454310    

Description Gennadii Altukhov 2017-08-21 10:52:01 UTC
Description of problem:
If no space left on device urlgrabber raises a KeyboardInterrupt exception with no error message and print some traceback on stderr instead.

Version-Release number of selected component (if applicable):
python-urlgrabber-3.9.1-11.el6.noarch

How reproducible:
100%

Steps to Reproduce:
1) create a lo device with 10 MB available:
# dd if=/dev/zero of=/disk bs=1M count=10
# losetup /dev/loop0 /disk
# mkfs.ext4 /dev/loop0

2) mount this dist to some directory, I'm using /var/satellite
# umount /var/satellite/
# mount /dev/loop0 /var/satellite/
# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        40G   13G   25G  35% /
tmpfs           1,9G  4,0K  1,9G   1% /dev/shm
/dev/loop0      976M  1,3M  924M   1% /var/satellite


3) execute the script below:
from urlgrabber import grabber

grabber.urlgrab("https://download.fedoraproject.org/pub/fedora/linux/releases/26/Server/x86_64/iso/Fedora-Server-netinst-x86_64-26-1.5.iso", "/var/satellite/fedora.iso")

Actual results:
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/urlgrabber/grabber.py", line 1107, in _retrieve
    self.fo.write(buf)
IOError: [Errno 28] No space left on device
Traceback (most recent call last):
  File "/tmp/url.py", line 4, in <module>
    grabber.urlgrab("https://download.fedoraproject.org/pub/fedora/linux/releases/26/Server/x86_64/iso/Fedora-Server-netinst-x86_64-26-1.5.iso", "/var/satellite/fedora.iso")
  File "/usr/lib/python2.6/site-packages/urlgrabber/grabber.py", line 626, in urlgrab
    return default_grabber.urlgrab(url, filename, **kwargs)
  File "/usr/lib/python2.6/site-packages/urlgrabber/grabber.py", line 994, in urlgrab
    return self._retry(opts, retryfunc, url, filename)
  File "/usr/lib/python2.6/site-packages/urlgrabber/grabber.py", line 895, in _retry
    r = apply(func, (opts,) + args, {})
  File "/usr/lib/python2.6/site-packages/urlgrabber/grabber.py", line 980, in retryfunc
    fo = PyCurlFileObject(url, filename, opts)
  File "/usr/lib/python2.6/site-packages/urlgrabber/grabber.py", line 1075, in __init__
    self._do_open()
  File "/usr/lib/python2.6/site-packages/urlgrabber/grabber.py", line 1378, in _do_open
    self._do_grab()
  File "/usr/lib/python2.6/site-packages/urlgrabber/grabber.py", line 1508, in _do_grab
    self._do_perform()
  File "/usr/lib/python2.6/site-packages/urlgrabber/grabber.py", line 1301, in _do_perform
    raise KeyboardInterrupt
KeyboardInterrupt


Expected results:
No error message "IOError: [Errno 28] No space left on device" printed on STDERR, a different type of an exception. 

Additional info:
On Fedora 25 this bug is fixed in version python-urlgrabber-3.10.1-9.fc25.noarch

Comment 2 Gennadii Altukhov 2017-08-21 11:00:27 UTC
As you can see above in the description there are two tracebacks. First of them is printed from within library directly on STDERR, the second one is from my script and it is OK. I'm complaining only about the first one of course.

Comment 3 toki 2017-09-30 15:23:42 UTC
The same exception is raised when a network interruption (send() or recv()) occurs.

I'm on python-urlgrabber-3.10-4.el7.noarch here.

In grabber.py

            elif errcode in (42, 55, 56):
                # this is probably wrong but ultimately this is what happens
                # we have a legit http code and a pycurl 'writer failed' code
                # which almost always means something aborted it from outside
                # since we cannot know what it is -I'm banking on it being
                # a ctrl-c. XXXX - if there's a way of going back two raises to
                # figure out what aborted the pycurl process FIXME
                raise KeyboardInterrupt

It is not probably wrong, it is definitely wrong.

Just below that, we have:

                             55 : _("Network error send()"),
                             56 : _("Network error recv()"),

Why not define a meaningful exception and raise that instead?

Cheers

Comment 4 toki 2017-09-30 15:25:17 UTC
Eh, I see it's fixed in later releases. So be it.

Comment 5 Jan Kurik 2017-12-06 11:45:02 UTC
Red Hat Enterprise Linux 6 is in the Production 3 Phase. During the Production 3 Phase, Critical impact Security Advisories (RHSAs) and selected Urgent Priority Bug Fix Advisories (RHBAs) may be released as they become available.

The official life cycle policy can be reviewed here:

http://redhat.com/rhel/lifecycle

This issue does not meet the inclusion criteria for the Production 3 Phase and will be marked as CLOSED/WONTFIX. If this remains a critical requirement, please contact Red Hat Customer Support to request a re-evaluation of the issue, citing a clear business justification. Note that a strong business justification will be required for re-evaluation. Red Hat Customer Support can be contacted via the Red Hat Customer Portal at the following URL:

https://access.redhat.com/