Add support to configure scheduler_default_filters

Add new config option: `scheduler-default-filters`.
This is unset by default, so cinder retains the default value for
scheduler_default_filters.

Closes-Bug: #1956727
Change-Id: I9777bf8fe5ddbb69689db60c2790e8a4be57e1ab
This commit is contained in:
Samuel Walladge 2022-01-25 09:39:30 +10:30
parent 77fdcf3e27
commit 7f97a6d30e
4 changed files with 35 additions and 1 deletions

View File

@ -408,4 +408,10 @@ options:
description: |
Max number of entries allowed in the image volume cache. 0 means
unlimited. Supported on OpenStack Ocata and newer.
scheduler-default-filters:
type: string
default:
description: |
List of comma-separated filter class names to use for filtering hosts
when not specified in the request.
The default filters varies based on OpenStack release.

View File

@ -152,6 +152,7 @@ class StorageBackendContext(OSContextGenerator):
'active_backends': backends,
'backends': ",".join(backends),
'default_volume_type': config('default-volume-type'),
'scheduler_default_filters': config('scheduler-default-filters'),
'image_volume_cache_enabled': config(
'image-volume-cache-enabled'),
'image_volume_cache_max_size_gb': config(

View File

@ -4,6 +4,10 @@
{% endfor %}
{%- endif %}
{% if scheduler_default_filters -%}
scheduler_default_filters = {{ scheduler_default_filters }}
{% endif -%}
{% if backends -%}
enabled_backends = {{ backends }}
{%- endif %}

View File

@ -126,6 +126,7 @@ class TestCinderContext(CharmTestCase):
{'active_backends': [],
'backends': '',
'default_volume_type': None,
'scheduler_default_filters': None,
'image_volume_cache_enabled': False,
'image_volume_cache_max_size_gb': 0,
'image_volume_cache_max_count': 0})
@ -149,6 +150,7 @@ class TestCinderContext(CharmTestCase):
{'backends': 'cinder-ceph',
'active_backends': ['cinder-ceph'],
'default_volume_type': None,
'scheduler_default_filters': None,
'image_volume_cache_enabled': False,
'image_volume_cache_max_size_gb': 0,
'image_volume_cache_max_count': 0})
@ -172,6 +174,7 @@ class TestCinderContext(CharmTestCase):
{'backends': 'cinder-ceph,cinder-vmware',
'active_backends': ['cinder-ceph', 'cinder-vmware'],
'default_volume_type': None,
'scheduler_default_filters': None,
'image_volume_cache_enabled': False,
'image_volume_cache_max_size_gb': 0,
'image_volume_cache_max_count': 0})
@ -195,10 +198,29 @@ class TestCinderContext(CharmTestCase):
{'backends': 'cinder-ceph,cinder-vmware',
'active_backends': ['cinder-ceph', 'cinder-vmware'],
'default_volume_type': 'my-preferred-volume-type',
'scheduler_default_filters': None,
'image_volume_cache_enabled': True,
'image_volume_cache_max_size_gb': 10,
'image_volume_cache_max_count': 100})
def test_storage_backend_default_filters_set(self):
self.test_config.set(
'scheduler-default-filters',
'DriverFilter,AvailabilityFilter'
)
self.config.side_effect = self.test_config.get
self.relation_ids.return_value = []
self.os_release.return_value = 'havana'
self.assertEqual(
contexts.StorageBackendContext()(),
{'active_backends': [],
'backends': '',
'default_volume_type': None,
'scheduler_default_filters': 'DriverFilter,AvailabilityFilter',
'image_volume_cache_enabled': False,
'image_volume_cache_max_size_gb': 0,
'image_volume_cache_max_count': 0})
def test_image_volume_cache(self):
rel_dict = {
'storage-backend': ['cinder-ceph:0'],
@ -221,6 +243,7 @@ class TestCinderContext(CharmTestCase):
{'backends': 'cinder-ceph',
'active_backends': ['cinder-ceph'],
'default_volume_type': None,
'scheduler_default_filters': None,
'image_volume_cache_enabled': enabled,
'image_volume_cache_max_size_gb': size,
'image_volume_cache_max_count': count})