Public bug reported: the _get_host_sysinfo_serial_os method try to read the machine-id file to get an UUID for the host operating system. If the file is there but it is empty the code will raise an exception while it tries to parse the content of the file.
To reproduce the issue just add this test to the nova/tests/unit/virt/libvirt/test_driver.py def test_get_guest_config_sysinfo_serial_os_empty_machine_id(self): self.flags(sysinfo_serial="os", group="libvirt") real_open = __builtin__.open with contextlib.nested( mock.patch.object(__builtin__, "open"), ) as (mock_open, ): theuuid = "" def fake_open(filename, *args, **kwargs): if filename == "/etc/machine-id": h = mock.MagicMock() h.read.return_value = theuuid h.__enter__.return_value = h return h return real_open(filename, *args, **kwargs) mock_open.side_effect = fake_open self._test_get_guest_config_sysinfo_serial(None) ** Affects: nova Importance: Undecided Assignee: Andrea Rosa (andrea-rosa-m) Status: In Progress ** Tags: low-hanging-fruit ** Changed in: nova Assignee: (unassigned) => Andrea Rosa (andrea-rosa-m) -- You received this bug notification because you are a member of Yahoo! Engineering Team, which is subscribed to OpenStack Compute (nova). https://bugs.launchpad.net/bugs/1475353 Title: _get_host_sysinfo_serial_os fails if the machine-id file is empty Status in OpenStack Compute (nova): In Progress Bug description: the _get_host_sysinfo_serial_os method try to read the machine-id file to get an UUID for the host operating system. If the file is there but it is empty the code will raise an exception while it tries to parse the content of the file. To reproduce the issue just add this test to the nova/tests/unit/virt/libvirt/test_driver.py def test_get_guest_config_sysinfo_serial_os_empty_machine_id(self): self.flags(sysinfo_serial="os", group="libvirt") real_open = __builtin__.open with contextlib.nested( mock.patch.object(__builtin__, "open"), ) as (mock_open, ): theuuid = "" def fake_open(filename, *args, **kwargs): if filename == "/etc/machine-id": h = mock.MagicMock() h.read.return_value = theuuid h.__enter__.return_value = h return h return real_open(filename, *args, **kwargs) mock_open.side_effect = fake_open self._test_get_guest_config_sysinfo_serial(None) To manage notifications about this bug go to: https://bugs.launchpad.net/nova/+bug/1475353/+subscriptions -- Mailing list: https://launchpad.net/~yahoo-eng-team Post to : yahoo-eng-team@lists.launchpad.net Unsubscribe : https://launchpad.net/~yahoo-eng-team More help : https://help.launchpad.net/ListHelp