Skip to content

Commit

Permalink
Merge "Handle "no RAM info was set" migration case" into stable/yoga
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and openstack-gerrit committed Dec 20, 2022
2 parents 2702040 + 4316234 commit a45cf40
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
22 changes: 22 additions & 0 deletions nova/tests/unit/virt/libvirt/test_guest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1040,3 +1040,25 @@ def test_job_info_operation_invalid(self, mock_stats, mock_info):

mock_stats.assert_called_once_with()
mock_info.assert_called_once_with()

@mock.patch.object(fakelibvirt.virDomain, "jobInfo")
@mock.patch.object(fakelibvirt.virDomain, "jobStats")
def test_job_stats_no_ram(self, mock_stats, mock_info):
mock_stats.side_effect = fakelibvirt.make_libvirtError(
fakelibvirt.libvirtError,
"internal error: migration was active, but no RAM info was set",
error_code=fakelibvirt.VIR_ERR_INTERNAL_ERROR,
error_message="migration was active, but no RAM info was set")

info = self.guest.get_job_info()

self.assertIsInstance(info, libvirt_guest.JobInfo)
self.assertEqual(fakelibvirt.VIR_DOMAIN_JOB_NONE, info.type)
self.assertEqual(0, info.time_elapsed)
self.assertEqual(0, info.time_remaining)
self.assertEqual(0, info.memory_total)
self.assertEqual(0, info.memory_processed)
self.assertEqual(0, info.memory_remaining)

mock_stats.assert_called_once_with()
self.assertFalse(mock_info.called)
7 changes: 7 additions & 0 deletions nova/virt/libvirt/guest.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,7 @@ def get_job_info(self):
stats = self._domain.jobStats()
return JobInfo(**stats)
except libvirt.libvirtError as ex:
errmsg = ex.get_error_message()
if ex.get_error_code() == libvirt.VIR_ERR_NO_SUPPORT:
# Remote libvirt doesn't support new API
LOG.debug("Missing remote virDomainGetJobStats: %s", ex)
Expand All @@ -667,6 +668,12 @@ def get_job_info(self):
# away completclsely
LOG.debug("Domain has shutdown/gone away: %s", ex)
return JobInfo(type=libvirt.VIR_DOMAIN_JOB_COMPLETED)
elif (ex.get_error_code() == libvirt.VIR_ERR_INTERNAL_ERROR and
errmsg and "migration was active, "
"but no RAM info was set" in errmsg):
LOG.debug("Migration is active or completed but "
"virDomainGetJobStats is missing ram: %s", ex)
return JobInfo(type=libvirt.VIR_DOMAIN_JOB_NONE)
else:
LOG.debug("Failed to get job stats: %s", ex)
raise
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
other:
- |
A workaround has been added to the libvirt driver to catch and pass
migrations that were previously failing with the error:
``libvirt.libvirtError: internal error: migration was active, but no RAM info was set``
See `bug 1982284`_ for more details.
.. _bug 1982284: https://bugs.launchpad.net/nova/+bug/1982284

0 comments on commit a45cf40

Please sign in to comment.