Skip to content

Commit 0ebcc5f

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Handle "no RAM info was set" migration case" into stable/zed
2 parents 643b0c7 + 00396fa commit 0ebcc5f

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
@@ -1053,3 +1053,25 @@ def test_job_info_operation_invalid(self, mock_stats, mock_info):
10531053

10541054
mock_stats.assert_called_once_with()
10551055
mock_info.assert_called_once_with()
1056+
1057+
@mock.patch.object(fakelibvirt.virDomain, "jobInfo")
1058+
@mock.patch.object(fakelibvirt.virDomain, "jobStats")
1059+
def test_job_stats_no_ram(self, mock_stats, mock_info):
1060+
mock_stats.side_effect = fakelibvirt.make_libvirtError(
1061+
fakelibvirt.libvirtError,
1062+
"internal error: migration was active, but no RAM info was set",
1063+
error_code=fakelibvirt.VIR_ERR_INTERNAL_ERROR,
1064+
error_message="migration was active, but no RAM info was set")
1065+
1066+
info = self.guest.get_job_info()
1067+
1068+
self.assertIsInstance(info, libvirt_guest.JobInfo)
1069+
self.assertEqual(fakelibvirt.VIR_DOMAIN_JOB_NONE, info.type)
1070+
self.assertEqual(0, info.time_elapsed)
1071+
self.assertEqual(0, info.time_remaining)
1072+
self.assertEqual(0, info.memory_total)
1073+
self.assertEqual(0, info.memory_processed)
1074+
self.assertEqual(0, info.memory_remaining)
1075+
1076+
mock_stats.assert_called_once_with()
1077+
self.assertFalse(mock_info.called)

nova/virt/libvirt/guest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,7 @@ def get_job_info(self):
674674
stats = self._domain.jobStats()
675675
return JobInfo(**stats)
676676
except libvirt.libvirtError as ex:
677+
errmsg = ex.get_error_message()
677678
if ex.get_error_code() == libvirt.VIR_ERR_NO_SUPPORT:
678679
# Remote libvirt doesn't support new API
679680
LOG.debug("Missing remote virDomainGetJobStats: %s", ex)
@@ -686,6 +687,12 @@ def get_job_info(self):
686687
# away completclsely
687688
LOG.debug("Domain has shutdown/gone away: %s", ex)
688689
return JobInfo(type=libvirt.VIR_DOMAIN_JOB_COMPLETED)
690+
elif (ex.get_error_code() == libvirt.VIR_ERR_INTERNAL_ERROR and
691+
errmsg and "migration was active, "
692+
"but no RAM info was set" in errmsg):
693+
LOG.debug("Migration is active or completed but "
694+
"virDomainGetJobStats is missing ram: %s", ex)
695+
return JobInfo(type=libvirt.VIR_DOMAIN_JOB_NONE)
689696
else:
690697
LOG.debug("Failed to get job stats: %s", ex)
691698
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)