Add ability to configure api_result_limit

In clouds with many containers or objects, listing them via Horizon
can cause a signficant increase of system load.

This patch enables configuration of the API_RESULT_LIMIT setting within
Horizon. This limits the maximum number of objects to display on a
single page before providing a paging element to paginate results.

Change-Id: Ifaf39d6c9bf549428afd7653243c82cd719956f6
Closes-Bug: 1775002
This commit is contained in:
Shane Peters 2018-07-02 13:38:11 -04:00
parent a0056fabd2
commit e58a1b2a3d
8 changed files with 28 additions and 5 deletions

View File

@ -357,3 +357,10 @@ options:
twice the number of CPU cores a service unit has. When deployed in twice the number of CPU cores a service unit has. When deployed in
a LXD container, this default value will be capped to 4 workers a LXD container, this default value will be capped to 4 workers
unless this configuration option is set. unless this configuration option is set.
api-result-limit:
type: int
default:
description: |
The maximum number of objects (e.g. Swift objects or Glance images) to
display on a single page before providing a paging element (a “more” link)
to paginate results.

View File

@ -198,6 +198,8 @@ class HorizonContext(OSContextGenerator):
'multi_domain': False if config('default-domain') else True, 'multi_domain': False if config('default-domain') else True,
"default_create_volume": config("default-create-volume"), "default_create_volume": config("default-create-volume"),
'image_formats': config('image-formats'), 'image_formats': config('image-formats'),
'api_result_limit': config('api-result-limit')
if config('api-result-limit') > 0 else 1000,
} }
return ctxt return ctxt

View File

@ -237,7 +237,7 @@ SECONDARY_ENDPOINT_TYPE = "{{ secondary_endpoint }}"
# The number of objects (Swift containers/objects or images) to display # The number of objects (Swift containers/objects or images) to display
# on a single page before providing a paging element (a "more" link) # on a single page before providing a paging element (a "more" link)
# to paginate results. # to paginate results.
API_RESULT_LIMIT = 1000 API_RESULT_LIMIT = {{ api_result_limit }}
API_RESULT_PAGE_SIZE = 20 API_RESULT_PAGE_SIZE = 20
# The timezone of the server. This should correspond with the timezone # The timezone of the server. This should correspond with the timezone

View File

@ -341,7 +341,7 @@ SECONDARY_ENDPOINT_TYPE = "{{ secondary_endpoint }}"
# The number of objects (Swift containers/objects or images) to display # The number of objects (Swift containers/objects or images) to display
# on a single page before providing a paging element (a "more" link) # on a single page before providing a paging element (a "more" link)
# to paginate results. # to paginate results.
API_RESULT_LIMIT = 1000 API_RESULT_LIMIT = {{ api_result_limit }}
API_RESULT_PAGE_SIZE = 20 API_RESULT_PAGE_SIZE = 20
# The size of chunk in bytes for downloading objects from Swift # The size of chunk in bytes for downloading objects from Swift

View File

@ -421,7 +421,7 @@ SECONDARY_ENDPOINT_TYPE = "{{ secondary_endpoint }}"
# The number of objects (Swift containers/objects or images) to display # The number of objects (Swift containers/objects or images) to display
# on a single page before providing a paging element (a "more" link) # on a single page before providing a paging element (a "more" link)
# to paginate results. # to paginate results.
API_RESULT_LIMIT = 1000 API_RESULT_LIMIT = {{ api_result_limit }}
API_RESULT_PAGE_SIZE = 20 API_RESULT_PAGE_SIZE = 20
# The size of chunk in bytes for downloading objects from Swift # The size of chunk in bytes for downloading objects from Swift

View File

@ -456,7 +456,7 @@ SECONDARY_ENDPOINT_TYPE = "{{ secondary_endpoint }}"
# The number of objects (Swift containers/objects or images) to display # The number of objects (Swift containers/objects or images) to display
# on a single page before providing a paging element (a "more" link) # on a single page before providing a paging element (a "more" link)
# to paginate results. # to paginate results.
API_RESULT_LIMIT = 1000 API_RESULT_LIMIT = {{ api_result_limit }}
API_RESULT_PAGE_SIZE = 20 API_RESULT_PAGE_SIZE = 20
# The size of chunk in bytes for downloading objects from Swift # The size of chunk in bytes for downloading objects from Swift

View File

@ -459,7 +459,7 @@ SECONDARY_ENDPOINT_TYPE = "{{ secondary_endpoint }}"
# The number of objects (Swift containers/objects or images) to display # The number of objects (Swift containers/objects or images) to display
# on a single page before providing a paging element (a "more" link) # on a single page before providing a paging element (a "more" link)
# to paginate results. # to paginate results.
API_RESULT_LIMIT = 1000 API_RESULT_LIMIT = {{ api_result_limit }}
API_RESULT_PAGE_SIZE = 20 API_RESULT_PAGE_SIZE = 20
# The size of chunk in bytes for downloading objects from Swift # The size of chunk in bytes for downloading objects from Swift

View File

@ -139,6 +139,7 @@ class TestHorizonContexts(CharmTestCase):
"allow_password_autocompletion": False, "allow_password_autocompletion": False,
"default_create_volume": True, "default_create_volume": True,
"image_formats": '', "image_formats": '',
"api_result_limit": 1000,
} }
) )
@ -164,6 +165,7 @@ class TestHorizonContexts(CharmTestCase):
"allow_password_autocompletion": False, "allow_password_autocompletion": False,
"default_create_volume": True, "default_create_volume": True,
"image_formats": '', "image_formats": '',
"api_result_limit": 1000,
} }
) )
@ -189,6 +191,7 @@ class TestHorizonContexts(CharmTestCase):
"allow_password_autocompletion": False, "allow_password_autocompletion": False,
"default_create_volume": True, "default_create_volume": True,
"image_formats": '', "image_formats": '',
"api_result_limit": 1000,
} }
) )
@ -214,6 +217,7 @@ class TestHorizonContexts(CharmTestCase):
"allow_password_autocompletion": False, "allow_password_autocompletion": False,
"default_create_volume": True, "default_create_volume": True,
"image_formats": '', "image_formats": '',
"api_result_limit": 1000,
} }
) )
@ -240,6 +244,7 @@ class TestHorizonContexts(CharmTestCase):
"allow_password_autocompletion": False, "allow_password_autocompletion": False,
"default_create_volume": True, "default_create_volume": True,
"image_formats": '', "image_formats": '',
"api_result_limit": 1000,
} }
) )
@ -269,6 +274,7 @@ class TestHorizonContexts(CharmTestCase):
"allow_password_autocompletion": False, "allow_password_autocompletion": False,
"default_create_volume": True, "default_create_volume": True,
"image_formats": '', "image_formats": '',
"api_result_limit": 1000,
} }
) )
@ -294,6 +300,7 @@ class TestHorizonContexts(CharmTestCase):
"allow_password_autocompletion": False, "allow_password_autocompletion": False,
"default_create_volume": True, "default_create_volume": True,
"image_formats": '', "image_formats": '',
"api_result_limit": 1000,
} }
) )
@ -319,6 +326,7 @@ class TestHorizonContexts(CharmTestCase):
"allow_password_autocompletion": False, "allow_password_autocompletion": False,
"default_create_volume": True, "default_create_volume": True,
"image_formats": '', "image_formats": '',
"api_result_limit": 1000,
} }
) )
@ -349,6 +357,7 @@ class TestHorizonContexts(CharmTestCase):
"allow_password_autocompletion": False, "allow_password_autocompletion": False,
"default_create_volume": True, "default_create_volume": True,
"image_formats": '', "image_formats": '',
"api_result_limit": 1000,
} }
) )
@ -374,6 +383,7 @@ class TestHorizonContexts(CharmTestCase):
"allow_password_autocompletion": False, "allow_password_autocompletion": False,
"default_create_volume": True, "default_create_volume": True,
"image_formats": '', "image_formats": '',
"api_result_limit": 1000,
} }
) )
@ -399,6 +409,7 @@ class TestHorizonContexts(CharmTestCase):
"allow_password_autocompletion": False, "allow_password_autocompletion": False,
"default_create_volume": True, "default_create_volume": True,
"image_formats": '', "image_formats": '',
"api_result_limit": 1000,
} }
) )
@ -425,6 +436,7 @@ class TestHorizonContexts(CharmTestCase):
"allow_password_autocompletion": True, "allow_password_autocompletion": True,
"default_create_volume": True, "default_create_volume": True,
"image_formats": '', "image_formats": '',
"api_result_limit": 1000,
} }
) )
@ -451,6 +463,7 @@ class TestHorizonContexts(CharmTestCase):
"allow_password_autocompletion": False, "allow_password_autocompletion": False,
"default_create_volume": False, "default_create_volume": False,
"image_formats": '', "image_formats": '',
"api_result_limit": 1000,
} }
) )
@ -477,6 +490,7 @@ class TestHorizonContexts(CharmTestCase):
"allow_password_autocompletion": False, "allow_password_autocompletion": False,
"default_create_volume": True, "default_create_volume": True,
"image_formats": 'iso qcow2 raw', "image_formats": 'iso qcow2 raw',
"api_result_limit": 1000,
} }
) )