From 26dcd5374e256101ed3de0df0aaa4eed8e759814 Mon Sep 17 00:00:00 2001 From: Pierre Riteau Date: Mon, 4 May 2026 15:00:12 +0200 Subject: [PATCH 1/2] [2024.1] pin setuptools in tox jobs setuptools 82 removed pkg_resources, breaking 2024.1 jobs. Pin to setuptools<82.0.0 in tox.ini. Detail reasoning in [1]. [1] https://review.opendev.org/c/openstack/requirements/+/976227 Change-Id: I9e255576010bf842c73a454dd847d0648438452b Signed-off-by: Pierre Riteau --- tox.ini | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tox.ini b/tox.ini index a51a6542..2524e72b 100644 --- a/tox.ini +++ b/tox.ini @@ -15,6 +15,7 @@ usedevelop = True deps = -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/2024.1} -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt + setuptools<82.0.0 commands = find . -type f -name "*.py[co]" -delete @@ -55,6 +56,7 @@ commands = oslopolicy-sample-generator --config-file=etc/oslo-policy-generator/c deps = -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/2024.1} -r{toxinidir}/requirements.txt -r{toxinidir}/doc/requirements.txt + setuptools<82.0.0 commands = sphinx-build -W --keep-going -b html doc/source doc/build/html # TODO(smcginnis) Temporarily disabling this as it fails. Error is that @@ -71,6 +73,7 @@ commands = sphinx-build -W --keep-going -b html doc/source doc/build/html # This environment is called from CI scripts to test and publish # the API Ref to docs.openstack.org. deps = -r{toxinidir}/doc/requirements.txt + setuptools<82.0.0 allowlist_externals = rm commands = rm -rf api-ref/build From a4e866bba2aa596dc9401935edcbf75c6a1e31c0 Mon Sep 17 00:00:00 2001 From: "nicolas.maillet-contoz" Date: Wed, 1 Oct 2025 11:18:01 +0200 Subject: [PATCH 2/2] Fix elasticsearch & opensearch requests Using list for metric_types in _build_must, in case it was not. The APIs expects a list for "type" in "terms". Story: 2011541 Task: 52868 Signed-off-by: Nicolas Maillet-Contoz Change-Id: Ia57e81dade3f54383d66a27c6935dda3779b090a (cherry picked from commit 677fc286f7fe856bcf692bd97fd9a1b4813cf8f6) --- cloudkitty/storage/v2/elasticsearch/client.py | 3 +++ cloudkitty/storage/v2/opensearch/client.py | 3 +++ cloudkitty/tests/storage/v2/elasticsearch/test_client.py | 7 +++++++ cloudkitty/tests/storage/v2/opensearch/test_client.py | 7 +++++++ releasenotes/notes/fix-elasticsearch-a9a37443f81b3a79.yaml | 5 +++++ 5 files changed, 25 insertions(+) create mode 100644 releasenotes/notes/fix-elasticsearch-a9a37443f81b3a79.yaml diff --git a/cloudkitty/storage/v2/elasticsearch/client.py b/cloudkitty/storage/v2/elasticsearch/client.py index 7716f039..01bdb500 100644 --- a/cloudkitty/storage/v2/elasticsearch/client.py +++ b/cloudkitty/storage/v2/elasticsearch/client.py @@ -76,6 +76,9 @@ def _build_must(start, end, metric_types, filters): must.append({'term': {'type': filters['type']}}) if metric_types: + if type(metric_types) is not list: + metric_types = [metric_types] + must.append({"terms": {"type": metric_types}}) return must diff --git a/cloudkitty/storage/v2/opensearch/client.py b/cloudkitty/storage/v2/opensearch/client.py index d5757c9b..e15bf77e 100644 --- a/cloudkitty/storage/v2/opensearch/client.py +++ b/cloudkitty/storage/v2/opensearch/client.py @@ -76,6 +76,9 @@ def _build_must(start, end, metric_types, filters): must.append({'term': {'type': filters['type']}}) if metric_types: + if type(metric_types) is not list: + metric_types = [metric_types] + must.append({"terms": {"type": metric_types}}) return must diff --git a/cloudkitty/tests/storage/v2/elasticsearch/test_client.py b/cloudkitty/tests/storage/v2/elasticsearch/test_client.py index 5d3158b4..c3493574 100644 --- a/cloudkitty/tests/storage/v2/elasticsearch/test_client.py +++ b/cloudkitty/tests/storage/v2/elasticsearch/test_client.py @@ -53,6 +53,13 @@ def test_build_must_with_filters(self): [{'term': {'type': 'awesome'}}], ) + def test_build_must_with_metric_type(self): + types = 'awesome' + self.assertEqual( + self.client._build_must(None, None, types, None), + [{'terms': {'type': ['awesome']}}], + ) + def test_build_must_with_metric_types(self): types = ['awesome', 'amazing'] self.assertEqual( diff --git a/cloudkitty/tests/storage/v2/opensearch/test_client.py b/cloudkitty/tests/storage/v2/opensearch/test_client.py index b33515c6..b3c2ae7a 100644 --- a/cloudkitty/tests/storage/v2/opensearch/test_client.py +++ b/cloudkitty/tests/storage/v2/opensearch/test_client.py @@ -53,6 +53,13 @@ def test_build_must_with_filters(self): [{'term': {'type': 'awesome'}}], ) + def test_build_must_with_metric_type(self): + types = 'awesome' + self.assertEqual( + self.client._build_must(None, None, types, None), + [{'terms': {'type': ['awesome']}}], + ) + def test_build_must_with_metric_types(self): types = ['awesome', 'amazing'] self.assertEqual( diff --git a/releasenotes/notes/fix-elasticsearch-a9a37443f81b3a79.yaml b/releasenotes/notes/fix-elasticsearch-a9a37443f81b3a79.yaml new file mode 100644 index 00000000..7568dbfb --- /dev/null +++ b/releasenotes/notes/fix-elasticsearch-a9a37443f81b3a79.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fix request to Elasticsearch/OpenSearch that has potentially not the + correct type.