From a37dda5013e1f8fb36e80ee551abea2510e1f2c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Weing=C3=A4rtner?= Date: Thu, 17 Aug 2023 17:27:50 -0300 Subject: [PATCH] Use correct metadata for metrics gathered from gnocchi Gnocchi fixed its `aggregates` API with PR https://github.com/gnocchixyz/gnocchi/pull/1059. Before that patch, the `aggregates` API would only return the latest metadata for the resource of the metric being handled. Therefore, for CloudKitty processing and reprocessing, we would always have the possibility of using the wrong attribute version to rate the computing resources. With this patch we propose to always use the correct metadata for the processing and reprocessing of CloudKitty. This means, we always use the metadata for the timestamp that we are collecting at Gnocchi. The patch was released under version 4.5.0 of Gnocchi. Change-Id: I31bc2cdf620fb5c0f561dc9de8c10d7882895cce --- cloudkitty/collector/gnocchi.py | 1 + cloudkitty/tests/collectors/test_gnocchi.py | 3 ++- ...regarding_gnocchi_version-99d5213c35950e39.yaml | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/add_warning_regarding_gnocchi_version-99d5213c35950e39.yaml diff --git a/cloudkitty/collector/gnocchi.py b/cloudkitty/collector/gnocchi.py index e02067f3..af0ddc05 100644 --- a/cloudkitty/collector/gnocchi.py +++ b/cloudkitty/collector/gnocchi.py @@ -385,6 +385,7 @@ class GnocchiCollector(collector.BaseCollector): 'resource_type': resource_type, 'start': start, 'stop': end, + 'use_history': True, 'groupby': self.conf[metric_name]['groupby'], 'search': self.extend_filter(*query_parameters), } diff --git a/cloudkitty/tests/collectors/test_gnocchi.py b/cloudkitty/tests/collectors/test_gnocchi.py index f765ed09..26b0318d 100644 --- a/cloudkitty/tests/collectors/test_gnocchi.py +++ b/cloudkitty/tests/collectors/test_gnocchi.py @@ -211,7 +211,8 @@ class GnocchiCollectorAggregationOperationTest(tests.TestCase): resource_type='resource_x', search={'=': {'type': 'resource_x'}}, start=self.start, stop=self.end, - granularity=3600 + granularity=3600, + use_history=True ) def test_multiple_confs(self): diff --git a/releasenotes/notes/add_warning_regarding_gnocchi_version-99d5213c35950e39.yaml b/releasenotes/notes/add_warning_regarding_gnocchi_version-99d5213c35950e39.yaml new file mode 100644 index 00000000..d91a9a1d --- /dev/null +++ b/releasenotes/notes/add_warning_regarding_gnocchi_version-99d5213c35950e39.yaml @@ -0,0 +1,14 @@ +--- +fixes: + - | + CloudKitty will always use the correct metadata for the + processing and reprocessing jobs. This means, we always use + the metadata for the timestamp that we are collecting at + Gnocchi backend.This is achieved with the use of + ``use_history=true`` in Gnocchi, which was released under + `version 4.5.0 `__. + Before that release, the ``aggregates`` API would only return + the latest metadata for the resource of the metric being handled. + Therefore, for CloudKitty processing and reprocessing, we would + always have the possibility of using the wrong attribute version + to rate the computing resources. \ No newline at end of file