Handle pagination of gnocchi's resource search API
Bug described in storyboard: https://storyboard.openstack.org/#!/story/2003404 Change-Id: Ia134fd1812c4a3adf4e820bc42575a66bc7299cd Story: 2003404 Task: 24534
This commit is contained in:
parent
1959f2d4f5
commit
f28a6fae83
|
@ -223,9 +223,20 @@ class GnocchiCollector(collector.BaseCollector):
|
|||
query_parameters.append(self.gen_filter(**kwargs))
|
||||
if q_filter:
|
||||
query_parameters.append(q_filter)
|
||||
resources = self._conn.resource.search(
|
||||
resource_type=resource_type,
|
||||
query=self.extend_filter(*query_parameters))
|
||||
|
||||
sorts = [extra_args['resource_key'] + ':asc']
|
||||
resources = []
|
||||
marker = None
|
||||
while True:
|
||||
resources_chunk = self._conn.resource.search(
|
||||
resource_type=resource_type,
|
||||
query=self.extend_filter(*query_parameters),
|
||||
sorts=sorts,
|
||||
marker=marker)
|
||||
if len(resources_chunk) < 1:
|
||||
break
|
||||
resources += resources_chunk
|
||||
marker = resources_chunk[-1][extra_args['resource_key']]
|
||||
return {res[extra_args['resource_key']]: res for res in resources}
|
||||
|
||||
def _fetch_metric(self, metric_name, start, end,
|
||||
|
|
Loading…
Reference in New Issue