Bug 1297588 - virt-install python urlfetcher.py error: http://URL/images/pxeboot/vmlinuz: 'int' object has no attribute 'isdigit'
virt-install python urlfetcher.py error: http://URL/images/pxeboot/vmlinuz: '...
Status: CLOSED UPSTREAM
Product: Virtualization Tools
Classification: Community
Component: virt-manager (Show other bugs)
unspecified
All Linux
unspecified Severity medium
: ---
: ---
Assigned To: Cole Robinson
:
Depends On:
Blocks: 1297900
  Show dependency treegraph
 
Reported: 2016-01-11 18:33 EST by bduff
Modified: 2016-01-12 12:51 EST (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1297900 (view as bug list)
Environment:
Last Closed: 2016-01-12 12:50:51 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description bduff 2016-01-11 18:33:03 EST
Description of problem:


Version-Release number of selected component (if applicable):
$ virt-manager --version
1.3.2

How reproducible:
virt-install with a net-install of RHEL 7.2 (but looks to be any netboot style install).  ISO pull off the web server.

Steps to Reproduce:
1. Run virt-install where my install is a net install (pulling down images/pxeboot/vmlinuz
2. Python error below

Actual results:
[Mon, 11 Jan 2016 22:44:00 virt-install 12769] ERROR (cli:306) Couldn't acquire file http://URL/images/pxeboot/vmlinuz: 'int' object has no attribute 'isdigit'
[Mon, 11 Jan 2016 22:44:00 virt-install 12769] DEBUG (cli:308) 
Traceback (most recent call last):
  File "/usr/share/virt-manager/virt-install", line 741, in start_install
    dom = guest.start_install(meter=meter, noboot=options.noreboot)
  File "/usr/share/virt-manager/virtinst/guest.py", line 482, in start_install
    self._prepare_install(meter, dry)
  File "/usr/share/virt-manager/virtinst/guest.py", line 303, in _prepare_install
    self.installer.prepare(self, meter)
  File "/usr/share/virt-manager/virtinst/installer.py", line 200, in prepare
    self._prepare(guest, meter)
  File "/usr/share/virt-manager/virtinst/distroinstaller.py", line 451, in _prepare
    self._prepare_kernel_url(guest, fetcher)
  File "/usr/share/virt-manager/virtinst/distroinstaller.py", line 360, in _prepare_kernel_url
    kernel, initrd, args = store.acquireKernel(guest)
  File "/usr/share/virt-manager/virtinst/urlfetcher.py", line 586, in acquireKernel
    return self._kernelFetchHelper(guest, kernelpath, initrdpath)
  File "/usr/share/virt-manager/virtinst/urlfetcher.py", line 645, in _kernelFetchHelper
    kernel = self.fetcher.acquireFile(kernelpath)
  File "/usr/share/virt-manager/virtinst/urlfetcher.py", line 156, in acquireFile
    self._grabURL(filename, fileobj)
  File "/usr/share/virt-manager/virtinst/urlfetcher.py", line 87, in _grabURL
    (url, str(e)))
ValueError: Couldn't acquire file http://URL/images/pxeboot/vmlinuz: 'int' object has no attribute 'isdigit'


Expected results:
[Mon, 11 Jan 2016 22:44:25 virt-install 12857] DEBUG (urlfetcher:89) Fetching URI: http://qnap01.csdt.sjm.com/kickstart/RHEL7.2_ISO/images/pxeboot/vmlinuz
...
[Mon, 11 Jan 2016 22:44:25 virt-install 12857] DEBUG (urlfetcher:89) Fetching URI: http://qnap01.csdt.sjm.com/kickstart/RHEL7.2_ISO/images/pxeboot/initrd.img

These expected results I get with the patch below.

Additional info:
$ diff -Nur /usr/share/virt-manager/virtinst/urlfetcher.py.orig /usr/share/virt-manager/virtinst/urlfetcher.py
--- /usr/share/virt-manager/virtinst/urlfetcher.py.orig 2016-01-11 23:26:59.147009928 +0000
+++ /usr/share/virt-manager/virtinst/urlfetcher.py      2016-01-11 22:44:46.476132803 +0000
@@ -187,6 +187,8 @@
         response = requests.get(url, stream=True)
         response.raise_for_status()
         size = response.headers.get('content-length')
+        if size == None:
+            size = "0"
         return response, size.isdigit() and int(size) or None
 
     def _write(self, urlobj, fileobj):
//end snip

This fixes the problem for me.

Since Transfer-Encoding "chunked" header is set, there is no Content-Length header, therefore you get None back.  Since this is only for a progress bar I don't care if the size is incorrect.
Comment 1 Cole Robinson 2016-01-12 12:50:51 EST
Thanks for the report, and the patch! It's better to default to size=None instead, since that gives better progressbar behavior. I pushed a fix:

commit eae7dc061968a83fef8ebb632c8f939621ff22b1
Author: Cole Robinson <crobinso@redhat.com>
Date:   Tue Jan 12 12:45:02 2016 -0500

    urlfetcher: Fix URL installs when content-length header missing
    
    Suggested-by: bduff@sjm.com

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