Not count disabled compute node for statistics
No server will be scheduled to disabled compute service, thus we should not count the corresponding compute node information. It's arguable if we should count for 'down' service, since service may be marked down because of communication error. If we do want to exclude the down service, we need passing the information from caller because the up/down state is not kepts in database, and it means compute and cell api changes. Closes-Bug: #1285259 Change-Id: I5e3e71ef30683c5eb5cc4462f58fa5f29d7c3f4b
This commit is contained in:
parent
33c1a195c8
commit
8cd2b89071
|
@ -684,7 +684,12 @@ def compute_node_statistics(context):
|
|||
func.sum(models.ComputeNode.running_vms),
|
||||
func.sum(models.ComputeNode.disk_available_least),
|
||||
base_model=models.ComputeNode,
|
||||
read_deleted="no").first()
|
||||
read_deleted="no").\
|
||||
filter(models.Service.disabled == False).\
|
||||
filter(
|
||||
models.Service.id ==
|
||||
models.ComputeNode.service_id).\
|
||||
first()
|
||||
|
||||
# Build a dict of the info--making no assumptions about result
|
||||
fields = ('count', 'vcpus', 'memory_mb', 'local_gb', 'vcpus_used',
|
||||
|
|
|
@ -5684,6 +5684,13 @@ class ComputeNodeTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
|||
for k, v in stats.iteritems():
|
||||
self.assertEqual(v, self.item[k])
|
||||
|
||||
def test_compute_node_statistics_disabled_service(self):
|
||||
serv = db.service_get_by_host_and_topic(
|
||||
self.ctxt, 'host1', CONF.compute_topic)
|
||||
db.service_update(self.ctxt, serv['id'], {'disabled': True})
|
||||
stats = db.compute_node_statistics(self.ctxt)
|
||||
self.assertEqual(stats.pop('count'), 0)
|
||||
|
||||
def test_compute_node_not_found(self):
|
||||
self.assertRaises(exception.ComputeHostNotFound, db.compute_node_get,
|
||||
self.ctxt, 100500)
|
||||
|
|
Loading…
Reference in New Issue