Add max-stacks-per-tenant config option

This configuration option allows operators to change the default of
how many stacks a project can have in parallel.

This key has been available since Mitaka:
https://docs.openstack.org/mitaka/config-reference/orchestration.html

Closes-Bug: #1871772
Change-Id: I4dc0008c1098a969d62ee4a8afe76de4bfb5c235
This commit is contained in:
Felipe Reyes
2020-04-13 12:50:03 -04:00
parent 35206c8ff8
commit 50d114aa1f
6 changed files with 25 additions and 0 deletions

View File

@ -262,3 +262,8 @@ options:
override YAML files in the service's policy.d directory. The resource
file should be a ZIP file containing at least one yaml file with a .yaml
or .yml extension. If False then remove the overrides.
max-stacks-per-tenant:
type: int
default:
description: |
Maximum number of stacks any one tenant may have active at one time.

View File

@ -146,3 +146,9 @@ class InstanceUserContext(context.OSContextGenerator):
instance_user = config('instance-user')
ctxt['instance_user'] = instance_user
return ctxt
class QuotaConfigurationContext(context.OSContextGenerator):
def __call__(self):
ctxt = {"max_stacks_per_tenant": config('max-stacks-per-tenant')}
return ctxt

View File

@ -70,6 +70,7 @@ from heat_context import (
HeatApacheSSLContext,
HeatHAProxyContext,
HeatPluginContext,
QuotaConfigurationContext,
)
TEMPLATES = 'templates/'
@ -133,6 +134,7 @@ CONFIG_FILES = OrderedDict([
HeatSecurityContext(),
InstanceUserContext(),
HeatPluginContext(),
QuotaConfigurationContext(),
context.SyslogContext(),
context.LogLevelContext(),
context.WorkerConfigContext(),

View File

@ -18,6 +18,9 @@ stack_domain_admin = heat_domain_admin
stack_domain_admin_password = {{ heat_domain_admin_passwd }}
stack_user_domain_name = heat
num_engine_workers = {{ workers }}
{%- if max_stacks_per_tenant %}
max_stacks_per_tenant = {{ max_stacks_per_tenant }}
{%- endif %}
{% if sections and 'DEFAULT' in sections -%}
{% for key, value in sections['DEFAULT'] -%}
{{ key }} = {{ value }}

View File

@ -18,6 +18,9 @@ stack_domain_admin = heat_domain_admin
stack_domain_admin_password = {{ heat_domain_admin_passwd }}
stack_user_domain_name = heat
num_engine_workers = {{ workers }}
{%- if max_stacks_per_tenant %}
max_stacks_per_tenant = {{ max_stacks_per_tenant }}
{%- endif %}
{% if sections and 'DEFAULT' in sections -%}
{% for key, value in sections['DEFAULT'] -%}
{{ key }} = {{ value }}

View File

@ -72,6 +72,12 @@ class TestHeatContext(CharmTestCase):
self.assertEqual(
heat_context.HeatIdentityServiceContext()(), final_result)
def test_quota_configuration_context(self):
expected = {'max_stacks_per_tenant': '999'}
self.config.side_effect = self.test_config.get
self.test_config.set('max-stacks-per-tenant', '999')
self.assertEqual(heat_context.QuotaConfigurationContext()(), expected)
class HeatPluginContextTest(CharmTestCase):