diff options
| author | Aaron Lee <aaron.lee@rackspace.com> | 2011-09-26 18:22:03 -0500 |
|---|---|---|
| committer | Aaron Lee <aaron.lee@rackspace.com> | 2011-09-27 13:35:30 -0500 |
| commit | 7dba1d9aa989760b190f1cf3bad2ed22bb2e2fc5 (patch) | |
| tree | 6107dc1205dbd94e01893395165bef60a32a24fa | |
| parent | d6b460e2e87e573500f6b521939895c6d93f5fdf (diff) | |
| download | nova-7dba1d9aa989760b190f1cf3bad2ed22bb2e2fc5.tar.gz nova-7dba1d9aa989760b190f1cf3bad2ed22bb2e2fc5.tar.xz nova-7dba1d9aa989760b190f1cf3bad2ed22bb2e2fc5.zip | |
Raise InsufficientFreeMemory
Kind of fixes bug 851374 & bug 858679
Raises InsufficientFreeMemory if an instance can't
start because of that. This will cause the normal
instance failure recovery to catch this problem,
set the state, and log the error. This also
removes instance_set_state from db/api.py as that
was causing these exceptions in the first place.
Change-Id: I199aa6900890531b175e28c3b93d8dfb88e135d0
| -rw-r--r-- | nova/exception.py | 4 | ||||
| -rw-r--r-- | nova/tests/test_xenapi.py | 2 | ||||
| -rw-r--r-- | nova/virt/xenapi/vmops.py | 7 |
3 files changed, 6 insertions, 7 deletions
diff --git a/nova/exception.py b/nova/exception.py index 6a50faa4a..f587173e1 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -818,3 +818,7 @@ class InstanceTypeMemoryTooSmall(NovaException): class InstanceTypeDiskTooSmall(NovaException): message = _("Instance type's disk is too small for requested image.") + + +class InsufficientFreeMemory(NovaException): + message = _("Insufficient free memory on compute node to start %(uuid)s.") diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index 2cacd2364..ec0104783 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -413,7 +413,7 @@ class XenAPIVMTestCase(test.TestCase): self.check_vm_params_for_linux() def test_spawn_not_enough_memory(self): - self.assertRaises(Exception, + self.assertRaises(exception.InsufficientFreeMemory, self._test_spawn, 1, 2, 3, "4") # m1.xlarge diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index bf4481d69..4b1d22bac 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -220,12 +220,7 @@ class VMOps(object): # Ensure enough free memory is available if not VMHelper.ensure_free_mem(self._session, instance): - LOG.exception(_('instance %(instance_name)s: not enough free ' - 'memory') % locals()) - db.instance_set_state(nova_context.get_admin_context(), - instance['id'], - power_state.SHUTDOWN) - return + raise exception.InsufficientFreeMemory(uuid=instance.uuid) disk_image_type = VMHelper.determine_disk_image_type(instance, context) kernel = None |
