Skip to content

Commit 458cd52

Browse files
authored
Merge pull request #41 from stackhpc/upstream/yoga-2023-02-27
Synchronise yoga with upstream
2 parents f1f7139 + 83f99ab commit 458cd52

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

cloudkitty/storage/v2/elasticsearch/client.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,14 @@ def retrieve(self, begin, end, filters, metric_types,
308308

309309
scroll_id = resp['_scroll_id']
310310
self._scroll_ids.add(scroll_id)
311-
total = resp['hits']['total']
311+
total_hits = resp['hits']['total']
312+
313+
if isinstance(total_hits, dict):
314+
LOG.debug("Total hits [%s] is a dict. Therefore, we only extract "
315+
"the 'value' attribute as the total option.", total_hits)
316+
total_hits = total_hits.get("value")
317+
318+
total = total_hits
312319
chunk = resp['hits']['hits']
313320

314321
output = chunk[offset:offset+limit if paginate else len(chunk)]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
fixes:
3+
- |
4+
Fix response format ``total`` for v2 dataframes API. The response for v2
5+
dataframes is ``{"total": 3}``. However, for Elasticsearch search response,
6+
the ``"hits.total"`` in the response body is ``{"value": 3, "relation":
7+
"eq"}``, which does not match the API response schema.

0 commit comments

Comments
 (0)