Comment 1 for bug 1519001

Revision history for this message
Paul Murray (pmurray) wrote :

The hypervisor is returning its own view of the number of vcpus used. This is copied to the compute_node record and is not reset before adding the resource tracker view. Code to reset the memory and disk is included in _update_usage_from_instances() as below. The extensible resource plugins are called here as well. Now the vcpu resource has gone and the accounting is directly in the compute_node object the vcpus_used should be reset to 0 here.

    def _update_usage_from_instances(self, context, instances):
        """Calculate resource usage based on instance utilization. This is
        different than the hypervisor's view as it will account for all
        instances assigned to the local compute host, even if they are not
        currently powered on.
        """
        self.tracked_instances.clear()

        # set some initial values, reserve room for host/hypervisor:
        self.compute_node.local_gb_used = CONF.reserved_host_disk_mb / 1024
        self.compute_node.memory_mb_used = CONF.reserved_host_memory_mb
        self.compute_node.free_ram_mb = (self.compute_node.memory_mb -
                                         self.compute_node.memory_mb_used)
        self.compute_node.free_disk_gb = (self.compute_node.local_gb -
                                          self.compute_node.local_gb_used)
        self.compute_node.current_workload = 0
        self.compute_node.running_vms = 0

        # Reset values for extended resources
        self.ext_resources_handler.reset_resources(self.compute_node,
                                                   self.driver)