Skip to content

Commit 4316234

Browse files
brettmilfordmelwitt
authored andcommitted
Handle "no RAM info was set" migration case
This handles the case where the live migration monitoring thread may race and call jobStats() after the migration has completed resulting in the following error: libvirt.libvirtError: internal error: migration was active, but no RAM info was set Closes-Bug: #1982284 Change-Id: I77fdfa9cffbd44b2889f49f266b2582bcc6a4267 (cherry picked from commit 9fea934) (cherry picked from commit 00396fa)
1 parent 2738317 commit 4316234

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

nova/tests/unit/virt/libvirt/test_guest.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,3 +1040,25 @@ def test_job_info_operation_invalid(self, mock_stats, mock_info):
10401040

10411041
mock_stats.assert_called_once_with()
10421042
mock_info.assert_called_once_with()
1043+
1044+
@mock.patch.object(fakelibvirt.virDomain, "jobInfo")
1045+
@mock.patch.object(fakelibvirt.virDomain, "jobStats")
1046+
def test_job_stats_no_ram(self, mock_stats, mock_info):
1047+
mock_stats.side_effect = fakelibvirt.make_libvirtError(
1048+
fakelibvirt.libvirtError,
1049+
"internal error: migration was active, but no RAM info was set",
1050+
error_code=fakelibvirt.VIR_ERR_INTERNAL_ERROR,
1051+
error_message="migration was active, but no RAM info was set")
1052+
1053+
info = self.guest.get_job_info()
1054+
1055+
self.assertIsInstance(info, libvirt_guest.JobInfo)
1056+
self.assertEqual(fakelibvirt.VIR_DOMAIN_JOB_NONE, info.type)
1057+
self.assertEqual(0, info.time_elapsed)
1058+
self.assertEqual(0, info.time_remaining)
1059+
self.assertEqual(0, info.memory_total)
1060+
self.assertEqual(0, info.memory_processed)
1061+
self.assertEqual(0, info.memory_remaining)
1062+
1063+
mock_stats.assert_called_once_with()
1064+
self.assertFalse(mock_info.called)

nova/virt/libvirt/guest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,7 @@ def get_job_info(self):
655655
stats = self._domain.jobStats()
656656
return JobInfo(**stats)
657657
except libvirt.libvirtError as ex:
658+
errmsg = ex.get_error_message()
658659
if ex.get_error_code() == libvirt.VIR_ERR_NO_SUPPORT:
659660
# Remote libvirt doesn't support new API
660661
LOG.debug("Missing remote virDomainGetJobStats: %s", ex)
@@ -667,6 +668,12 @@ def get_job_info(self):
667668
# away completclsely
668669
LOG.debug("Domain has shutdown/gone away: %s", ex)
669670
return JobInfo(type=libvirt.VIR_DOMAIN_JOB_COMPLETED)
671+
elif (ex.get_error_code() == libvirt.VIR_ERR_INTERNAL_ERROR and
672+
errmsg and "migration was active, "
673+
"but no RAM info was set" in errmsg):
674+
LOG.debug("Migration is active or completed but "
675+
"virDomainGetJobStats is missing ram: %s", ex)
676+
return JobInfo(type=libvirt.VIR_DOMAIN_JOB_NONE)
670677
else:
671678
LOG.debug("Failed to get job stats: %s", ex)
672679
raise
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
other:
3+
- |
4+
A workaround has been added to the libvirt driver to catch and pass
5+
migrations that were previously failing with the error:
6+
7+
``libvirt.libvirtError: internal error: migration was active, but no RAM info was set``
8+
9+
See `bug 1982284`_ for more details.
10+
11+
.. _bug 1982284: https://bugs.launchpad.net/nova/+bug/1982284

0 commit comments

Comments
 (0)