Add dsl_iterators_limit config option

To remove hardcoded constant called 'ITERATORS_LIMIT', that can be
exceeded (2000) having big amount of objects. It is easy to achieve
in big cloud with user that is allowed to view lots of resources.

Change-Id: I818561ca044bad505402b69d22a41ea892e15fcc
Closes-Bug: #1690179
This commit is contained in:
Margarita Shakhova 2017-07-03 13:18:38 -07:00 committed by Felipe Monteiro
parent 0b35823605
commit 9a4bafa5d4
6 changed files with 23 additions and 5 deletions

View File

@ -176,6 +176,10 @@ murano_opts = [
cfg.IntOpt('api_workers',
help=_('Number of API workers')),
cfg.IntOpt('dsl_iterators_limit', default=2000,
help=_('Maximum number of elements that can be iterated per '
'object type.')),
]
networking_opts = [

View File

@ -16,7 +16,6 @@ import semantic_version
EXPRESSION_MEMORY_QUOTA = 512 * 1024
ITERATORS_LIMIT = 2000
CTX_ACTIONS_ONLY = '?actionsOnly'
CTX_ALLOW_PROPERTY_WRITES = '$?allowPropertyWrites'

View File

@ -16,6 +16,7 @@ import inspect
import os.path
import eventlet
from oslo_config import cfg
import six
from yaql.language import expressions as yaql_expressions
from yaql.language import specs
@ -28,6 +29,7 @@ from murano.dsl import dsl_types
from murano.dsl import helpers
CONF = cfg.CONF
NO_VALUE = utils.create_marker('NO_VALUE')
@ -349,7 +351,8 @@ def to_mutable(obj, yaql_engine=None):
else:
return utils.convert_output_data(value, limit_func, engine, rec)
limiter = lambda it: utils.limit_iterable(it, constants.ITERATORS_LIMIT)
limiter = lambda it: utils.limit_iterable(
it, CONF.murano.dsl_iterators_limit)
return converter(obj, limiter, yaql_engine, converter)

View File

@ -26,6 +26,7 @@ import weakref
import eventlet.greenpool
import eventlet.greenthread
from oslo_config import cfg
import semantic_version
import six
from yaql.language import contexts
@ -41,6 +42,7 @@ from murano.dsl import exceptions
_threads_sequencer = 0
# type string: ns.something.MyApp[/1.2.3-alpha][@my.package.fqn]
TYPE_RE = re.compile(r'([a-zA-Z0-9_.]+)(?:/([^@]+))?(?:@([a-zA-Z0-9_.]+))?$')
CONF = cfg.CONF
def evaluate(value, context, freeze=True):
@ -64,7 +66,7 @@ def evaluate(value, context, freeze=True):
return list_type(
evaluate(t, context, freeze)
for t in yaqlutils.limit_iterable(
value, constants.ITERATORS_LIMIT))
value, CONF.murano.dsl_iterators_limit))
elif isinstance(value, dsl_types.MuranoObjectInterface):
return value.object
else:

View File

@ -14,6 +14,7 @@
import weakref
from oslo_config import cfg
import yaql
from yaql.language import contexts
from yaql.language import conventions
@ -30,8 +31,9 @@ from murano.dsl import helpers
from murano.dsl import yaql_functions
CONF = cfg.CONF
ENGINE_10_OPTIONS = {
'yaql.limitIterators': constants.ITERATORS_LIMIT,
'yaql.limitIterators': CONF.murano.dsl_iterators_limit,
'yaql.memoryQuota': constants.EXPRESSION_MEMORY_QUOTA,
'yaql.convertSetsToLists': True,
'yaql.convertTuplesToLists': True,
@ -39,7 +41,7 @@ ENGINE_10_OPTIONS = {
}
ENGINE_12_OPTIONS = {
'yaql.limitIterators': constants.ITERATORS_LIMIT,
'yaql.limitIterators': CONF.murano.dsl_iterators_limit,
'yaql.memoryQuota': constants.EXPRESSION_MEMORY_QUOTA,
'yaql.convertSetsToLists': True,
'yaql.convertTuplesToLists': True

View File

@ -0,0 +1,8 @@
---
fixes:
- |
Remove hardcoded constant called 'ITERATORS_LIMIT', that can be
exceeded (2000) having big amount of objects.
Introduce dsl_iterators_limit configuration option instead of
constant.