Skip to content

Commit 1778a9c

Browse files
sbauzagibizer
authored andcommitted
Add logging to find test cases leaking libvirt threads
We see functional test failures due to leaked libvirt event handling thread weaking up after its original test finished and importing libvirt. If it happens when the libvirt package import is poisoned then the currently executing test will fail. This patch logs the name of the test case that leaked the libvirt event handling thread. We will revert his before RC1. Change-Id: I3146e9afb411056d004fc118ccfa31126a3c6b15 Related-Bug: #1946339
1 parent 7ea9aac commit 1778a9c

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

nova/tests/fixtures/nova.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1822,6 +1822,24 @@ def __init__(self, test, modules):
18221822

18231823
def find_spec(self, fullname, path, target=None):
18241824
if fullname in self.modules:
1825+
current = eventlet.getcurrent()
1826+
# NOTE(gibi) not all eventlet spawn is under our control, so
1827+
# there can be senders without test_case_id set, find the first
1828+
# ancestor that was spawned from nova.utils.spawn[_n] and
1829+
# therefore has the id set.
1830+
while (
1831+
current is not None and
1832+
not getattr(current, 'test_case_id', None)
1833+
):
1834+
current = current.parent
1835+
1836+
if current is not None:
1837+
self.test.tc_id = current.test_case_id
1838+
LOG.warning(
1839+
"!!!---!!! TestCase ID %s hit the import poison while "
1840+
"importing %s. If you see this in a failed functional "
1841+
"test then please let #openstack-nova on IRC know "
1842+
"about it. !!!---!!!", current.test_case_id, fullname)
18251843
self.test.fail_message = (
18261844
f"This test imports the '{fullname}' module, which it "
18271845
f'should not in the test environment. Please add '
@@ -1832,6 +1850,7 @@ def find_spec(self, fullname, path, target=None):
18321850
def __init__(self, module_names):
18331851
self.module_names = module_names
18341852
self.fail_message = ''
1853+
self.tc_id = None
18351854
if isinstance(module_names, str):
18361855
self.module_names = {module_names}
18371856
self.meta_path_finder = self.ForbiddenModules(self, self.module_names)
@@ -1849,6 +1868,13 @@ def cleanup(self):
18491868
# there (which is also what self.assert* and self.fail() do underneath)
18501869
# will not work to cause a failure in the test.
18511870
if self.fail_message:
1871+
if self.tc_id is not None:
1872+
LOG.warning(
1873+
"!!!---!!! TestCase ID %s hit the import poison. If you "
1874+
"see this in a failed functional test then please let "
1875+
"#openstack-nova on IRC know about it. !!!---!!!",
1876+
self.tc_id
1877+
)
18521878
raise ImportError(self.fail_message)
18531879

18541880

nova/virt/libvirt/driver.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10061,6 +10061,24 @@ def live_migration_abort(self, instance):
1006110061
:param instance: instance object that is in migration
1006210062

1006310063
"""
10064+
current = eventlet.getcurrent()
10065+
# NOTE(gibi) not all eventlet spawn is under our control, so
10066+
# there can be senders without test_case_id set, find the first
10067+
# ancestor that was spawned from nova.utils.spawn[_n] and
10068+
# therefore has the id set.
10069+
while (
10070+
current is not None and
10071+
not getattr(current, 'test_case_id', None)
10072+
):
10073+
current = current.parent
10074+
10075+
if current is not None:
10076+
LOG.warning(
10077+
"!!!---!!! live_migration_abort thread was spawned by "
10078+
"TestCase ID: %s. If you see this in a failed functional test "
10079+
"then please let #openstack-nova on IRC know about it. "
10080+
"!!!---!!!", current.test_case_id
10081+
)
1006410082

1006510083
guest = self._host.get_guest(instance)
1006610084
dom = guest._domain

0 commit comments

Comments
 (0)