test_virt_drivers.LibvirtConnTestCase fails if /etc/machine-id is empty

Bug #1551900 reported by Matt Riedemann
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Matt Riedemann
Kilo
Fix Released
Undecided
Matt Riedemann
Liberty
Fix Released
Undecided
Matt Riedemann

Bug Description

This is related to bug 1475353 but in this case unit tests fail if the file exists but is empty. Either way we shouldn't be trying to read from a file on the system in unit tests, so we should set the CONF.libvirt.sysinfo_serial config option value to 'none' in the tests.

Example failure (this is from Juno):

nova.tests.virt.test_virt_drivers.LibvirtConnTestCase.test_block_stats
----------------------------------------------------------------------

Captured traceback:
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):
      File "nova/tests/virt/test_virt_drivers.py", line 54, in wrapped_func
        return f(self, *args, **kwargs)
      File "nova/tests/virt/test_virt_drivers.py", line 521, in test_block_stats
        instance_ref, network_info = self._get_running_instance()
      File "nova/tests/virt/test_virt_drivers.py", line 228, in _get_running_instance
        [], 'herp', network_info=network_info)
      File "nova/virt/libvirt/driver.py", line 2661, in spawn
        write_to_disk=True)
      File "nova/virt/libvirt/driver.py", line 4182, in _get_guest_xml
        context)
      File "nova/virt/libvirt/driver.py", line 3863, in _get_guest_config
        guest.sysinfo = self._get_guest_config_sysinfo(instance)
      File "nova/virt/libvirt/driver.py", line 3582, in _get_guest_config_sysinfo
        sysinfo.system_serial = self._sysinfo_serial_func()
      File "nova/virt/libvirt/driver.py", line 3571, in _get_host_sysinfo_serial_auto
        return self._get_host_sysinfo_serial_os()
      File "nova/virt/libvirt/driver.py", line 3567, in _get_host_sysinfo_serial_os
        return str(uuid.UUID(f.read().split()[0]))
    IndexError: list index out of range
    Traceback (most recent call last):
    _StringException: Empty attachments:
      stderr
      stdout

Matt Riedemann (mriedem)
Changed in nova:
importance: Undecided → Medium
status: New → Confirmed
assignee: nobody → Matt Riedemann (mriedem)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/286776

Changed in nova:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/liberty)

Fix proposed to branch: stable/liberty
Review: https://review.openstack.org/286841

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/kilo)

Fix proposed to branch: stable/kilo
Review: https://review.openstack.org/286848

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/286776
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=6c3991e881312d715d08f94158d72f8c37dfc6a4
Submitter: Jenkins
Branch: master

commit 6c3991e881312d715d08f94158d72f8c37dfc6a4
Author: Matt Riedemann <email address hidden>
Date: Tue Mar 1 13:59:36 2016 -0500

    libvirt: set libvirt.sysinfo_serial='none' for virt driver tests

    The default value for the sysinfo_serial option is 'auto' which
    tries to read from the /etc/machine-id file if it exists and is
    not empty.

    Unit tests should not be dependent on trying to read from system
    files outside the virtual environment, so for the generic virt
    driver tests set the config option value to 'none' so we don't
    do anything for the sysinfo_serial option.

    Change-Id: Ib9ba0ec2c1690d93eadb63e699740e4ba988cce1
    Closes-Bug: #1551900

Changed in nova:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (stable/liberty)

Reviewed: https://review.openstack.org/286841
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=2da1d8ba76b0041b71ef8f39f74e3d2330a4dc4d
Submitter: Jenkins
Branch: stable/liberty

commit 2da1d8ba76b0041b71ef8f39f74e3d2330a4dc4d
Author: Matt Riedemann <email address hidden>
Date: Tue Mar 1 13:59:36 2016 -0500

    libvirt: set libvirt.sysinfo_serial='none' for virt driver tests

    The default value for the sysinfo_serial option is 'auto' which
    tries to read from the /etc/machine-id file if it exists and is
    not empty.

    Unit tests should not be dependent on trying to read from system
    files outside the virtual environment, so for the generic virt
    driver tests set the config option value to 'none' so we don't
    do anything for the sysinfo_serial option.

    Change-Id: Ib9ba0ec2c1690d93eadb63e699740e4ba988cce1
    Closes-Bug: #1551900
    (cherry picked from commit 6c3991e881312d715d08f94158d72f8c37dfc6a4)

Revision history for this message
Doug Hellmann (doug-hellmann) wrote : Fix included in openstack/nova 13.0.0.0b3

This issue was fixed in the openstack/nova 13.0.0.0b3 development milestone.

Revision history for this message
Doug Hellmann (doug-hellmann) wrote : Fix included in openstack/nova 12.0.2

This issue was fixed in the openstack/nova 12.0.2 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (stable/kilo)

Reviewed: https://review.openstack.org/286848
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=54ff59b0ad0d4be9ebcfaebcef7a2a30b287f367
Submitter: Jenkins
Branch: stable/kilo

commit 54ff59b0ad0d4be9ebcfaebcef7a2a30b287f367
Author: Matt Riedemann <email address hidden>
Date: Tue Mar 1 13:59:36 2016 -0500

    libvirt: set libvirt.sysinfo_serial='none' for virt driver tests

    The default value for the sysinfo_serial option is 'auto' which
    tries to read from the /etc/machine-id file if it exists and is
    not empty.

    Unit tests should not be dependent on trying to read from system
    files outside the virtual environment, so for the generic virt
    driver tests set the config option value to 'none' so we don't
    do anything for the sysinfo_serial option.

    Change-Id: Ib9ba0ec2c1690d93eadb63e699740e4ba988cce1
    Closes-Bug: #1551900
    (cherry picked from commit 6c3991e881312d715d08f94158d72f8c37dfc6a4)
    (cherry picked from commit 2da1d8ba76b0041b71ef8f39f74e3d2330a4dc4d)

Revision history for this message
Doug Hellmann (doug-hellmann) wrote : Fix included in openstack/nova 2015.1.4

This issue was fixed in the openstack/nova 2015.1.4 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

This issue was fixed in the openstack/nova 2015.1.4 release.

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.