Merge "Skip to poll and publish when no resources found"
This commit is contained in:
commit
2117ba760c
@ -113,14 +113,18 @@ class PollingTask(object):
|
||||
[pollster.obj.default_discovery], discovery_cache)
|
||||
key = Resources.key(source, pollster)
|
||||
source_resources = list(self.resources[key].get(discovery_cache))
|
||||
polling_resources = (source_resources or pollster_resources or
|
||||
agent_resources)
|
||||
if not polling_resources:
|
||||
LOG.info(_("Skip polling pollster %s, no resources found"),
|
||||
pollster.name)
|
||||
continue
|
||||
with self.publishers[source.name] as publisher:
|
||||
try:
|
||||
samples = list(pollster.obj.get_samples(
|
||||
manager=self.manager,
|
||||
cache=cache,
|
||||
resources=(source_resources or
|
||||
pollster_resources or
|
||||
agent_resources)
|
||||
resources=polling_resources
|
||||
))
|
||||
publisher(samples)
|
||||
except Exception as err:
|
||||
|
@ -740,3 +740,15 @@ class BaseAgentManagerTestCase(base.BaseTestCase):
|
||||
len(p_coord.extract_my_subset.call_args_list))
|
||||
for c in expected:
|
||||
self.assertIn(c, p_coord.extract_my_subset.call_args_list)
|
||||
|
||||
def test_skip_polling_and_publish_with_no_resources(self):
|
||||
self.pipeline_cfg[0]['resources'] = []
|
||||
self.setup_pipeline()
|
||||
polling_task = self.mgr.setup_polling_tasks().values()[0]
|
||||
pollster = list(polling_task.pollster_matches)[0][1]
|
||||
LOG = mock.MagicMock()
|
||||
with mock.patch('ceilometer.agent.LOG', LOG):
|
||||
polling_task.poll_and_publish()
|
||||
if not self.mgr.discover():
|
||||
LOG.info.assert_called_with('Skip polling pollster %s, no '
|
||||
'resources found', pollster.name)
|
||||
|
Loading…
x
Reference in New Issue
Block a user