Merge "NoUniqueMatch: ClientException on Gnocchi publisher"
This commit is contained in:
commit
39f3721209
@ -261,22 +261,31 @@ class GnocchiPublisher(publisher.ConfigPublisherBase):
|
|||||||
return self._gnocchi_project_id
|
return self._gnocchi_project_id
|
||||||
with self._gnocchi_project_id_lock:
|
with self._gnocchi_project_id_lock:
|
||||||
if self._gnocchi_project_id is None:
|
if self._gnocchi_project_id is None:
|
||||||
|
if not self.filter_project:
|
||||||
|
LOG.debug(
|
||||||
|
"Multiple executions were locked on "
|
||||||
|
"self._gnocchi_project_id_lock`. This execution "
|
||||||
|
"should no call `_internal_gnocchi_project_discovery` "
|
||||||
|
"as `self.filter_project` is None.")
|
||||||
|
return None
|
||||||
try:
|
try:
|
||||||
project = self._ks_client.projects.find(
|
project = self._ks_client.projects.find(
|
||||||
name=self.filter_project,
|
name=self.filter_project,
|
||||||
domain=self.filter_domain)
|
domain=self.filter_domain)
|
||||||
except ka_exceptions.NotFound:
|
except ka_exceptions.NotFound:
|
||||||
LOG.warning('project %s not found in keystone,'
|
LOG.warning('Filtered project [%s] not found in keystone, '
|
||||||
' ignoring the filter_project '
|
'ignoring the filter_project option' %
|
||||||
'option', self.filter_project)
|
self.filter_project)
|
||||||
|
|
||||||
self.filter_project = None
|
self.filter_project = None
|
||||||
return None
|
return None
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.exception('fail to retrieve filtered project ')
|
LOG.exception('Failed to retrieve filtered project [%s].'
|
||||||
|
% self.filter_project)
|
||||||
raise
|
raise
|
||||||
self._gnocchi_project_id = project.id
|
self._gnocchi_project_id = project.id
|
||||||
LOG.debug("filtered project found: %s",
|
LOG.debug("Filtered project [%s] found with ID [%s].",
|
||||||
self._gnocchi_project_id)
|
self.filter_project, self._gnocchi_project_id)
|
||||||
return self._gnocchi_project_id
|
return self._gnocchi_project_id
|
||||||
|
|
||||||
def _is_swift_account_sample(self, sample):
|
def _is_swift_account_sample(self, sample):
|
||||||
@ -301,11 +310,29 @@ class GnocchiPublisher(publisher.ConfigPublisherBase):
|
|||||||
if operation:
|
if operation:
|
||||||
return rd, operation
|
return rd, operation
|
||||||
|
|
||||||
|
def filter_gnocchi_activity_openstack(self, samples):
|
||||||
|
"""Skip sample generated by gnocchi itself
|
||||||
|
|
||||||
|
This method will filter out the samples that are generated by
|
||||||
|
Gnocchi itself.
|
||||||
|
"""
|
||||||
|
filtered_samples = []
|
||||||
|
for sample in samples:
|
||||||
|
if not self._is_gnocchi_activity(sample):
|
||||||
|
filtered_samples.append(sample)
|
||||||
|
LOG.debug("Sample [%s] is not a Gnocchi activity; therefore, "
|
||||||
|
"we do not filter it out and push it to Gnocchi.",
|
||||||
|
sample)
|
||||||
|
else:
|
||||||
|
LOG.debug("Sample [%s] is a Gnocchi activity; therefore, "
|
||||||
|
"we filter it out and do not push it to Gnocchi.",
|
||||||
|
sample)
|
||||||
|
return filtered_samples
|
||||||
|
|
||||||
def publish_samples(self, data):
|
def publish_samples(self, data):
|
||||||
self.ensures_archives_policies()
|
self.ensures_archives_policies()
|
||||||
|
|
||||||
# NOTE(sileht): skip sample generated by gnocchi itself
|
data = self.filter_gnocchi_activity_openstack(data)
|
||||||
data = [s for s in data if not self._is_gnocchi_activity(s)]
|
|
||||||
|
|
||||||
def value_to_sort(object_to_sort):
|
def value_to_sort(object_to_sort):
|
||||||
value = object_to_sort.resource_id
|
value = object_to_sort.resource_id
|
||||||
|
@ -339,9 +339,9 @@ class PublisherTest(base.BaseTestCase):
|
|||||||
def test_activity_gnocchi_project_not_found(self, logger):
|
def test_activity_gnocchi_project_not_found(self, logger):
|
||||||
self.ks_client.projects.find.side_effect = ka_exceptions.NotFound
|
self.ks_client.projects.find.side_effect = ka_exceptions.NotFound
|
||||||
self._do_test_activity_filter(2)
|
self._do_test_activity_filter(2)
|
||||||
logger.warning.assert_called_with('project %s not found in '
|
logger.warning.assert_called_with(
|
||||||
'keystone, ignoring the '
|
'Filtered project [service] not found in keystone, ignoring the '
|
||||||
'filter_project option', 'service')
|
'filter_project option')
|
||||||
|
|
||||||
def test_activity_filter_match_swift_event(self):
|
def test_activity_filter_match_swift_event(self):
|
||||||
self.samples[0].name = 'storage.objects.outgoing.bytes'
|
self.samples[0].name = 'storage.objects.outgoing.bytes'
|
||||||
@ -749,8 +749,11 @@ class PublisherWorkflowTest(base.BaseTestCase,
|
|||||||
resource_type = resource_definition.cfg['resource_type']
|
resource_type = resource_definition.cfg['resource_type']
|
||||||
|
|
||||||
expected_debug = [
|
expected_debug = [
|
||||||
mock.call('filtered project found: %s',
|
mock.call('Filtered project [%s] found with ID [%s].', 'service',
|
||||||
'a2d42c23-d518-46b6-96ab-3fba2e146859'),
|
'a2d42c23-d518-46b6-96ab-3fba2e146859'),
|
||||||
|
mock.call('Sample [%s] is not a Gnocchi activity; therefore, we '
|
||||||
|
'do not filter it out and push it to Gnocchi.',
|
||||||
|
self.sample),
|
||||||
mock.call('Processing sample [%s] for resource ID [%s].',
|
mock.call('Processing sample [%s] for resource ID [%s].',
|
||||||
self.sample, resource_id),
|
self.sample, resource_id),
|
||||||
mock.call('Executing batch resource metrics measures for resource '
|
mock.call('Executing batch resource metrics measures for resource '
|
||||||
|
Loading…
x
Reference in New Issue
Block a user