Skip to content

Commit cd1a03b

Browse files
authored
Merge pull request #142 from stackhpc/upstream/2024.1-2026-05-11
Synchronise 2024.1 with upstream
2 parents 97be2eb + a4e866b commit cd1a03b

6 files changed

Lines changed: 28 additions & 0 deletions

File tree

cloudkitty/storage/v2/elasticsearch/client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ def _build_must(start, end, metric_types, filters):
7676
must.append({'term': {'type': filters['type']}})
7777

7878
if metric_types:
79+
if type(metric_types) is not list:
80+
metric_types = [metric_types]
81+
7982
must.append({"terms": {"type": metric_types}})
8083

8184
return must

cloudkitty/storage/v2/opensearch/client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ def _build_must(start, end, metric_types, filters):
7676
must.append({'term': {'type': filters['type']}})
7777

7878
if metric_types:
79+
if type(metric_types) is not list:
80+
metric_types = [metric_types]
81+
7982
must.append({"terms": {"type": metric_types}})
8083

8184
return must

cloudkitty/tests/storage/v2/elasticsearch/test_client.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ def test_build_must_with_filters(self):
5353
[{'term': {'type': 'awesome'}}],
5454
)
5555

56+
def test_build_must_with_metric_type(self):
57+
types = 'awesome'
58+
self.assertEqual(
59+
self.client._build_must(None, None, types, None),
60+
[{'terms': {'type': ['awesome']}}],
61+
)
62+
5663
def test_build_must_with_metric_types(self):
5764
types = ['awesome', 'amazing']
5865
self.assertEqual(

cloudkitty/tests/storage/v2/opensearch/test_client.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ def test_build_must_with_filters(self):
5353
[{'term': {'type': 'awesome'}}],
5454
)
5555

56+
def test_build_must_with_metric_type(self):
57+
types = 'awesome'
58+
self.assertEqual(
59+
self.client._build_must(None, None, types, None),
60+
[{'terms': {'type': ['awesome']}}],
61+
)
62+
5663
def test_build_must_with_metric_types(self):
5764
types = ['awesome', 'amazing']
5865
self.assertEqual(
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
fixes:
3+
- |
4+
Fix request to Elasticsearch/OpenSearch that has potentially not the
5+
correct type.

tox.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ usedevelop = True
1515
deps = -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/2024.1}
1616
-r{toxinidir}/requirements.txt
1717
-r{toxinidir}/test-requirements.txt
18+
setuptools<82.0.0
1819

1920
commands =
2021
find . -type f -name "*.py[co]" -delete
@@ -55,6 +56,7 @@ commands = oslopolicy-sample-generator --config-file=etc/oslo-policy-generator/c
5556
deps = -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/2024.1}
5657
-r{toxinidir}/requirements.txt
5758
-r{toxinidir}/doc/requirements.txt
59+
setuptools<82.0.0
5860
commands = sphinx-build -W --keep-going -b html doc/source doc/build/html
5961

6062
# 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
7173
# This environment is called from CI scripts to test and publish
7274
# the API Ref to docs.openstack.org.
7375
deps = -r{toxinidir}/doc/requirements.txt
76+
setuptools<82.0.0
7477
allowlist_externals = rm
7578
commands =
7679
rm -rf api-ref/build

0 commit comments

Comments
 (0)