Fix image-volume-cache configuration defaults

The image_volume_cache_max_count and image_volume_cache_max_size_gb
options were incorrectly being written to cinder.conf with a value of
"None" when not configured.

This occurred because config.get returns None for values with a null
default, this value was being placed into a dictionary and sent over
relation data to charm-cinder which renders it directly from a list of
key-value pairs.

Fix the handling of these options not to include them in the dictionary
if they are None.

Closes-Bug: #1976465
Change-Id: I61781fa5d837d0ed5191d8a92cc8e0bdf600c08a
This commit is contained in:
Trent Lloyd 2022-06-01 15:46:39 +08:00
parent 7eae2f1a7c
commit b3a5d3b358
1 changed files with 8 additions and 5 deletions

View File

@ -48,11 +48,14 @@ class CinderpurestorageCharm(
self.config.get('use-chap'))])
if self.config.get('use-image-cache'):
image_cache = [
('image_volume_cache_max_size_gb',
self.config.get('image-volume-cache-max-size-gb', 0)),
('image_volume_cache_max_count',
self.config.get('image-volume-cache-max-count', 0))]
max_size_gb = self.config.get('image-volume-cache-max-size-gb')
if max_size_gb is not None:
image_cache.append(('image_volume_cache_max_size_gb',
max_size_gb))
max_count = self.config.get('image-volume-cache-max-count')
if max_count is not None:
image_cache.append(('image_volume_cache_max_count', max_count))
if self.config.get('use-replication'):
replication_device = 'backend_id:' + \