From 2613a4251485bdb5ee7c8e7dea83970b47f00325 Mon Sep 17 00:00:00 2001 From: Matt Crees Date: Wed, 15 May 2024 16:39:50 +0100 Subject: [PATCH] Fix v1 summary/total with ES/OS storage backend ``metric_types`` is used as a list in ``_build_must``, so we need to pass ``service`` as a single-itemed list. Story: 2011128 Task: 50106 Change-Id: I144a005c180ed67a16985f93efa930ddf937c989 --- cloudkitty/storage/v2/elasticsearch/client.py | 2 ++ cloudkitty/storage/v2/opensearch/client.py | 2 ++ ...mary-and-total-with-es-os-backend-9540741b80819672.yaml | 7 +++++++ 3 files changed, 11 insertions(+) create mode 100644 releasenotes/notes/fix-v1-summary-and-total-with-es-os-backend-9540741b80819672.yaml diff --git a/cloudkitty/storage/v2/elasticsearch/client.py b/cloudkitty/storage/v2/elasticsearch/client.py index 7716f039..525f8655 100644 --- a/cloudkitty/storage/v2/elasticsearch/client.py +++ b/cloudkitty/storage/v2/elasticsearch/client.py @@ -366,6 +366,8 @@ class ElasticsearchClient(object): if not paginate: offset = 0 + metric_types = [metric_types] if metric_types else None + must = self._build_must(begin, end, metric_types, filters) should = self._build_should(filters) composite = self._build_composite(groupby) if groupby else None diff --git a/cloudkitty/storage/v2/opensearch/client.py b/cloudkitty/storage/v2/opensearch/client.py index d5757c9b..6242019f 100644 --- a/cloudkitty/storage/v2/opensearch/client.py +++ b/cloudkitty/storage/v2/opensearch/client.py @@ -363,6 +363,8 @@ class OpenSearchClient(object): if not paginate: offset = 0 + metric_types = [metric_types] if metric_types else None + must = self._build_must(begin, end, metric_types, filters) should = self._build_should(filters) composite = self._build_composite(groupby) if groupby else None diff --git a/releasenotes/notes/fix-v1-summary-and-total-with-es-os-backend-9540741b80819672.yaml b/releasenotes/notes/fix-v1-summary-and-total-with-es-os-backend-9540741b80819672.yaml new file mode 100644 index 00000000..24623b82 --- /dev/null +++ b/releasenotes/notes/fix-v1-summary-and-total-with-es-os-backend-9540741b80819672.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Fixed a bug where ``openstack rating summary get -s `` and + ``openstack rating total get -s `` would fail when using the + Elasticsearch or OpenSearch storage backends. See story 2011128 + `_ for more details.