Bug 1297900 - virt-install python urlfetcher.py error: http://URL/images/pxeboot/vmlinuz: 'int' object has no attribute 'isdigit'
Summary: virt-install python urlfetcher.py error: http://URL/images/pxeboot/vmlinuz: '...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: virt-manager
Version: 23
Hardware: All
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Cole Robinson
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On: 1297588
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-01-12 17:51 UTC by Cole Robinson
Modified: 2016-03-25 01:24 UTC (History)
5 users (show)

Fixed In Version: virt-manager-1.3.2-2.fc23
Doc Type: Bug Fix
Doc Text:
Clone Of: 1297588
Environment:
Last Closed: 2016-03-25 01:24:00 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Cole Robinson 2016-01-12 17:51:31 UTC
+++ This bug was initially created as a clone of Bug #1297588 +++

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.

--- Additional comment from Cole Robinson on 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>
Date:   Tue Jan 12 12:45:02 2016 -0500

    urlfetcher: Fix URL installs when content-length header missing
    
    Suggested-by: bduff

Comment 1 Fedora Update System 2016-03-17 15:05:13 UTC
virt-manager-1.3.2-2.fc23 has been submitted as an update to Fedora 23. https://bodhi.fedoraproject.org/updates/FEDORA-2016-edb0c8d5df

Comment 2 Fedora Update System 2016-03-19 01:25:25 UTC
virt-manager-1.3.2-2.fc23 has been pushed to the Fedora 23 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-edb0c8d5df

Comment 3 Fedora Update System 2016-03-25 01:23:53 UTC
virt-manager-1.3.2-2.fc23 has been pushed to the Fedora 23 stable repository. If problems still persist, please make note of it in this bug report.


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