Merge "Fix 500 errors in the API when request context bears no project_id"
This commit is contained in:
commit
df1b5530ae
|
@ -62,6 +62,9 @@ class DataFramesController(rest.RestController):
|
|||
if pecan.request.context.is_admin:
|
||||
filters = {scope_key: tenant_id} if tenant_id else None
|
||||
else:
|
||||
# Unscoped non-admin user
|
||||
if project_id is None:
|
||||
return {'dataframes': []}
|
||||
filters = {scope_key: project_id}
|
||||
try:
|
||||
resp = backend.retrieve(
|
||||
|
|
|
@ -84,6 +84,12 @@ class DataFrameList(base.BaseResource):
|
|||
metric_types = None
|
||||
|
||||
if not flask.request.context.is_admin:
|
||||
if flask.request.context.project_id is None:
|
||||
# Unscoped non-admin user
|
||||
return {
|
||||
'total': 0,
|
||||
'dataframes': []
|
||||
}
|
||||
scope_key = CONF.collect.scope_key
|
||||
if filters:
|
||||
filters[scope_key] = flask.request.context.project_id
|
||||
|
|
|
@ -45,6 +45,13 @@ class Summary(base.BaseResource):
|
|||
end = end or tzutils.get_next_month()
|
||||
|
||||
if not flask.request.context.is_admin:
|
||||
if flask.request.context.project_id is None:
|
||||
# Unscoped non-admin user
|
||||
return {
|
||||
'total': 0,
|
||||
'columns': [],
|
||||
'results': [],
|
||||
}
|
||||
filters['project_id'] = flask.request.context.project_id
|
||||
|
||||
metric_types = [filters.pop('type')] if 'type' in filters else None
|
||||
|
|
|
@ -161,6 +161,7 @@ class InfluxClient(object):
|
|||
|
||||
@staticmethod
|
||||
def _get_filter(key, value):
|
||||
format_string = ''
|
||||
if isinstance(value, six.string_types):
|
||||
format_string = """"{}"='{}'"""
|
||||
elif isinstance(value, (six.integer_types, float)):
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
fixes:
|
||||
- |
|
||||
The 500 errors happening on some API endpoints when keystone authentication
|
||||
is enabled and the request context bears no ``project_id`` have been fixed.
|
Loading…
Reference in New Issue