diff --git a/ceilometer/compute/manager.py b/ceilometer/compute/manager.py index ec1c1e80..137a5cf8 100644 --- a/ceilometer/compute/manager.py +++ b/ceilometer/compute/manager.py @@ -80,4 +80,5 @@ class AgentManager(manager.Manager): # FIXME(dhellmann): How do we get a list of instances without # talking directly to the database? for instance in self.db.instance_get_all_by_host(context, self.host): - self.poll_instance(context, instance) + if instance['vm_state'] != 'error': + self.poll_instance(context, instance) diff --git a/tests/compute/test_manager.py b/tests/compute/test_manager.py index 09f39ad3..a18549cb 100644 --- a/tests/compute/test_manager.py +++ b/tests/compute/test_manager.py @@ -68,18 +68,20 @@ class TestRunTasks(base.TestCase): # Set up a fake instance value to be returned by # instance_get_all_by_host() so when the manager gets the list # of instances to poll we can control the results. - self.instance = 'faux instance' + self.instance = {'name': 'faux', 'vm_state': 'active'} + stillborn_instance = {'name': 'stillborn', 'vm_state': 'error'} self.mox.StubOutWithMock(self.mgr.db, 'instance_get_all_by_host') self.mgr.db.instance_get_all_by_host( None, self.mgr.host, - ).AndReturn([self.instance]) + ).AndReturn([self.instance, stillborn_instance]) self.mox.ReplayAll() # Invoke the periodic tasks to call the pollsters. self.mgr.periodic_tasks(None) def test_message(self): + assert len(self.Pollster.counters) == 1 assert self.Pollster.counters[0][1] is self.instance def test_notifications(self):