virtualization script chokes on emtpy 'timeout' line in config file

Bug #1186259 reported by Jeff Lane 
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Checkbox
Fix Released
High
Jeff Lane 

Bug Description

Two related issues. In theory, if I have a config filed in /etc/checkbox.d the virtualization test should read that, get the path to the local copy of my cloud image, and use that for testing without needing to download anything. IN reality, what happens is that even with the config file present, the test STILL tries downloading cloud images from the internet. When there's no network access, this causes a traceback (actually a series of nested tracebacks :( )

Here's my current config file:
bladernr@klaatu:~/development/checkbox/scripts$ cat /etc/checkbox.d/virtualization.cfg
[KVM]
image:/home/bladernr/Downloads/ISOs/CloudImages/quantal-server-cloudimg-amd64.img
timeout:

WITH network access (internet), the script immediately starts downloading an image from cloud-images.ubuntu.com, even though I specified a local copy in my config file.

REGARDLESS of network access, if I use the --image option explicity, it does the right thing and tries to use my local image.

WITHOUT network access, the script ignores my config file at the start (it probably would try reading later), immediately tries downloading an image and the lack of internet access results in a traceback:

bladernr@klaatu:~/development/checkbox/scripts$ ./virtualization kvm --debug
Executing KVM Test
WARNING:root:invalid literal for int() with base 10: ''
DEBUG:root:Downloading raring-server-cloudimg-i386-disk1.img, from http://cloud-images.ubuntu.com
Traceback (most recent call last):
  File "/usr/lib/python3.3/urllib/request.py", line 1252, in do_open
    h.request(req.get_method(), req.selector, req.data, headers)
  File "/usr/lib/python3.3/http/client.py", line 1061, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python3.3/http/client.py", line 1099, in _send_request
    self.endheaders(body)
  File "/usr/lib/python3.3/http/client.py", line 1057, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python3.3/http/client.py", line 902, in _send_output
    self.send(msg)
  File "/usr/lib/python3.3/http/client.py", line 840, in send
    self.connect()
  File "/usr/lib/python3.3/http/client.py", line 818, in connect
    self.timeout, self.source_address)
  File "/usr/lib/python3.3/socket.py", line 417, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
FileNotFoundError: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./virtualization", line 275, in <module>
    main()
  File "./virtualization", line 272, in main
    args.func(args)
  File "./virtualization", line 241, in test_kvm
    result = kvm_test.start()
  File "./virtualization", line 180, in start
    self.image = self.download_image()
  File "./virtualization", line 75, in download_image
    resp = urllib.request.urlretrieve(image_url, cloud_iso)
  File "/usr/lib/python3.3/urllib/request.py", line 185, in urlretrieve
    with contextlib.closing(urlopen(url, data)) as fp:
  File "/usr/lib/python3.3/urllib/request.py", line 160, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.3/urllib/request.py", line 473, in open
    response = self._open(req, data)
  File "/usr/lib/python3.3/urllib/request.py", line 491, in _open
    '_open', req)
  File "/usr/lib/python3.3/urllib/request.py", line 451, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.3/urllib/request.py", line 1272, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/usr/lib/python3.3/urllib/request.py", line 1255, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 2] No such file or directory>
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 68, in apport_excepthook
    binary = os.path.realpath(os.path.join(os.getcwd(), sys.argv[0]))
FileNotFoundError: [Errno 2] No such file or directory

Original exception was:
Traceback (most recent call last):
  File "/usr/lib/python3.3/urllib/request.py", line 1252, in do_open
    h.request(req.get_method(), req.selector, req.data, headers)
  File "/usr/lib/python3.3/http/client.py", line 1061, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python3.3/http/client.py", line 1099, in _send_request
    self.endheaders(body)
  File "/usr/lib/python3.3/http/client.py", line 1057, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python3.3/http/client.py", line 902, in _send_output
    self.send(msg)
  File "/usr/lib/python3.3/http/client.py", line 840, in send
    self.connect()
  File "/usr/lib/python3.3/http/client.py", line 818, in connect
    self.timeout, self.source_address)
  File "/usr/lib/python3.3/socket.py", line 417, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
FileNotFoundError: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./virtualization", line 275, in <module>
    main()
  File "./virtualization", line 272, in main
    args.func(args)
  File "./virtualization", line 241, in test_kvm
    result = kvm_test.start()
  File "./virtualization", line 180, in start
    self.image = self.download_image()
  File "./virtualization", line 75, in download_image
    resp = urllib.request.urlretrieve(image_url, cloud_iso)
  File "/usr/lib/python3.3/urllib/request.py", line 185, in urlretrieve
    with contextlib.closing(urlopen(url, data)) as fp:
  File "/usr/lib/python3.3/urllib/request.py", line 160, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.3/urllib/request.py", line 473, in open
    response = self._open(req, data)
  File "/usr/lib/python3.3/urllib/request.py", line 491, in _open
    '_open', req)
  File "/usr/lib/python3.3/urllib/request.py", line 451, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.3/urllib/request.py", line 1272, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/usr/lib/python3.3/urllib/request.py", line 1255, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 2] No such file or directory>

Related branches

Revision history for this message
Jeff Lane  (bladernr) wrote :

First issue... that may be the only issue... if timeout: is empty in the config file, the parsing of that file creates an exception because of the explicit attempt to cast an empty string to an int.

Changed in checkbox:
status: Confirmed → In Progress
Revision history for this message
Jeff Lane  (bladernr) wrote :

Ok, so the first issue was as above. The empty timeout line in the config file was causing the config parser to choke trying to cast an empty string to an int.

Added error handling to trap that and handle it appropriately.

Added a lot of other error handling as other issues can arrise while parsing the relatively simple config file.

Jeff Lane  (bladernr)
summary: - virtualization script does not honor config file and tracebacks when no
- network is presentlk
+ virtualization script chokes on emtpy 'timeout' line in config file
Daniel Manrique (roadmr)
Changed in checkbox:
status: In Progress → Fix Committed
Changed in checkbox:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.