Skip to content

Commit

Permalink
Fix bugs in resource tracker and cleanup
Browse files Browse the repository at this point in the history
Fixes bugs in resource tracker:
* Handle disk oversubscription
* Handle suspended/powered off instances

The usage model is changed to the old style that is
based on actual instance usage on a compute host.
(Not the current point in time of the hypervisor's
 reported host stats)

There is now a 'limits' filter property that can be passed from
the scheduler to the compute node to indicate that
oversubscription of resources is desired:

The 'limits' filter property is a dict with the following possible
keys:

* memory_mb - Specifies the memory ceiling for the compute node.
* disk_gb - Specifies the disk space ceiling for the compute node.
* vcpu - Specifies the max number of vcpus for the compute node.

There is also some general cleanup and additional unit tests in
an attempt to simplify down this function.

bug 1048842
bug 1052157

Change-Id: I6ee851b8c03234a78a64d9f5c494dfc7059cdda4
  • Loading branch information
Brian Elliott authored and comstud committed Sep 20, 2012
1 parent 64a45f0 commit 8e85140
Show file tree
Hide file tree
Showing 16 changed files with 813 additions and 367 deletions.
18 changes: 9 additions & 9 deletions nova/compute/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,7 @@ def _instance_update(self, context, instance_uuid, **kwargs):

(old_ref, instance_ref) = self.db.instance_update_and_get_original(
context, instance_uuid, kwargs)
self.resource_tracker.update_load_stats_for_instance(context,
instance_ref)
self.resource_tracker.update_usage(context, instance_ref)
notifications.send_update(context, old_ref, instance_ref)

return instance_ref
Expand Down Expand Up @@ -480,10 +479,14 @@ def _run_instance(self, context, request_spec,
network_info = self._allocate_network(context, instance,
requested_networks)
try:
memory_mb_limit = filter_properties.get('memory_mb_limit',
None)
with self.resource_tracker.instance_resource_claim(context,
instance, memory_mb_limit=memory_mb_limit):
limits = filter_properties.get('limits', {})
with self.resource_tracker.resource_claim(context, instance,
limits):
# Resources are available to build this instance here,
# mark it as belonging to this host:
self._instance_update(context, instance['uuid'],
host=self.host, launched_on=self.host)

block_device_info = self._prep_block_device(context,
instance)
instance = self._spawn(context, instance, image_meta,
Expand Down Expand Up @@ -684,7 +687,6 @@ def _start_building(self, context, instance):
LOG.audit(_('Starting instance...'), context=context,
instance=instance)
self._instance_update(context, instance['uuid'],
host=self.host, launched_on=self.host,
vm_state=vm_states.BUILDING,
task_state=None,
expected_task_state=(task_states.SCHEDULING,
Expand Down Expand Up @@ -889,8 +891,6 @@ def _delete_instance(self, context, instance):
self.db.instance_destroy(context, instance_uuid)
system_meta = self.db.instance_system_metadata_get(context,
instance_uuid)
# mark resources free
self.resource_tracker.free_resources(context)
self._notify_about_instance_usage(context, instance, "delete.end",
system_metadata=system_meta)

Expand Down

0 comments on commit 8e85140

Please sign in to comment.