Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cloudkitty/storage/v2/elasticsearch/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions cloudkitty/storage/v2/opensearch/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions cloudkitty/tests/storage/v2/elasticsearch/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
7 changes: 7 additions & 0 deletions cloudkitty/tests/storage/v2/opensearch/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
5 changes: 5 additions & 0 deletions releasenotes/notes/fix-elasticsearch-a9a37443f81b3a79.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
fixes:
- |
Fix request to Elasticsearch/OpenSearch that has potentially not the
correct type.
3 changes: 3 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading