File: Fix_elasticsearch_and_opensearch_requests.patch

package info (click to toggle)
cloudkitty 23.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,528 kB
  • sloc: python: 21,803; sh: 528; makefile: 226; pascal: 54
file content (40 lines) | stat: -rw-r--r-- 1,567 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Author: nicolas.maillet-contoz <nicolas.maillet-contoz@infomaniak.com>
Date: Wed, 01 Oct 2025 11:18:01 +0200
Subject: 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 <nicolas.maillet-contoz@infomaniak.com>
Change-Id: Ia57e81dade3f54383d66a27c6935dda3779b090a
Origin: https://review.opendev.org/c/openstack/cloudkitty/+/962653
Last-Update: 2025-10-01

diff --git a/cloudkitty/storage/v2/elasticsearch/client.py b/cloudkitty/storage/v2/elasticsearch/client.py
index 98dc8a2..eb87934 100644
--- a/cloudkitty/storage/v2/elasticsearch/client.py
+++ b/cloudkitty/storage/v2/elasticsearch/client.py
@@ -78,6 +78,9 @@
             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 868af2c..b46122e 100644
--- a/cloudkitty/storage/v2/opensearch/client.py
+++ b/cloudkitty/storage/v2/opensearch/client.py
@@ -78,6 +78,9 @@
             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